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: <form>
<select>
<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: $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
333
21
Other forums
styling a RadioButtonList
HiI need to have a radio button and close to it, its lable, then a space then another set of those.
How to form a xml form table with a single sql statement..?
Hi everyone,
I don't know if this is going to be a duplicate thread but i couldn't
question about header() security
is is safe to just use the header() function to redirect someone if they are, say, not logged in? or
how to load php class from another domain?
how to load php class from another domain?
frames get header location..
i have two frames, one top, one bottom. how do i do a form on the bottom frame that gives me the ur
dropdown menu
Hello everbody,
I am php newbie.
I need to develop a program that once click the drop do
Using Windows message as a Handle
Hi,
I am writing one of my first multithreaded programs.
In one of the thread,
Move array index to end
Hey guys,
Quick question:
I have an array that looks like this:
Code: [Select]$var =
Select question
Hi,
First I would like to say that php is pretty new for me..
so please don't shoot me if
Session is not saving
I am not trying to do anything too fancy, I am just trying to get some $_SESSION data to save and us