using variables in another page
Posted on
16th Feb 2014 07:03 pm by
admin
I have a test database set up on localhost. I have a form that I can type a name into, hit the button and it puts the name into the database and into a list on my page. it works fine. Now, I wanted to make a drop down list with all the names so that you could select one to remove that name from the database. So I did this
Code: [Select]<form>
<select>
Did you know?Explore Trending and Topic pages for more stories like this.
<option><?php echo $name ?></option>
</select>
</form>
What that did was list the very last name in the list. What I thought it would do was list all the names based on the loop that I have set up to read all the names from the database. which is this
Code: [Select]$mysql = new mysqli('localhost', 'myusername', 'mypass', 'mydatabase') or die('not working');
$result = $mysql->query("SELECT * FROM myTable") or die($mysql->error);
if($result)
{
while($row = $result->fetch_object())
{
$name = $row->names;
echo $name . "<br />";
}
}
Now the while loop is in a file I called results and it is included in the index page with an include. I thought this would give me access to the $name variable and allow me to use it the same way it's being used in the loop. of course I was wrong, so how do I use it the same way?
No comments posted yet
Your Answer:
Login to answer
232
38
Other forums
Adding to the next element in a multidimensional array
Hi, I'm trying to add a value to $node->field_spaces['nid'] where x is the next available spo
connect() succeeds but accept() does not?
Please help me with this problem. I'm working on a time-sensitive project where I'm using TCP socket
Problem with DB connection
Hello there! I'm new to this forum and I'm new to PHP coding also. I wrote something that doesn't ma
Displaying data from MySql a different way
Hi all,
I'm pretty new to php and MySql and have hit a problem.
I am able to display data
Help with lottery style system?
I'm working on a currency system for forums and it is going to have a type of lottery system built i
have trouble in a if condition
The if below is working ok, it check when indexes, name, zipcode and state are empty.
Code: &
Saving data from a form into a file
Hey everybody,
Sorry, I am really new to PHP coding and such but a project kind of got thrust
try catch error
I have been trying try catch but, I can't get it to work. The code opens a non existing file called
Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to
Multiple arrays inside data
Hi,
Simple question. I have a column called "array" in my database, and inserted in