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>
<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 Like 38 Dislike
Previous forums Next forums
Other forums

Multidimensional array problems in $_POST
I'm having trouble with a three-dimensional $_POST array. It starts as a two-dimensional array on th

Deleted Delivery but material wont return
We deleted a delivery but the material its still pending.

We made a reverse goods movemen

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

Dynamic Array using glob?
Is there an easier way to do this?

I am trying to get create a dyamic array based on files wi

GIS appliction help
I found some tutorials in the internet to develop a map application I don't want to use google maps

form problem
Hi all, I think this is going to be easy to resolve but for I have been looking at it to long and I

Images outside webroot
Im hopeing someone can help me with this because i cant figure it out.I have setup an ASP.NET websit

Escaped characters
I have a script that allows you to post news to the home page of my site. Along with the news is the

Inserting multiple records from single form
I've found a number of threads that deal with this issue, but I'm new to php and coding language so

pop3 and fsockopen
So I am able to connect to the pop3 server, log in, and check how many messages there are. I am hav

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash