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
38
Other forums
Help on query replacing the date
Hi Pals,
i want to replace the current date in a column to some value say C or D or any n
Wierd if else problem
Hi guys,
this probably aint wierd for you, but it seems like php is playin up to me. may b i
Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple
Help with page encoding issue and weird characters
I'm trying to write a screen scraper and when I pull out the lines of the html file that I'm interes
Problem displaying "scraped" XML data
I'm basicly having trouble displaying XML data scraped from an URL using cURL.
What the code
Bluetooth RSSI & VIsta
Okie I got 4 Bluetooth adapters, a DBT-120 by Dlink, A Zonet Microsoft Bluetooth which is what I use
Php Mysql Page Loading Notice
Hi all,
I was wondering if there is a way (Sure there is) of showing a message or an image wh
FPDF Help
I've been playing with the FPDF module. I was building a form and rolling right along and then sudde
puting for loop in 1 value
hi ,
how do i put this code in 1 value:
Code: <?php
for ($i=1; $i<=5; $i
About imagecopyresampled()
Hello,
I am looking to use this function to resize parts of an image to a fixed thumbnail siz