I am trying to populate a drop down box from mysql database but for some reason i am getting nothing there are no errors
here is my code
<?php
$con = mysql_connect("localhost","dbuname","tdbpassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DBname", $con);
echo "<select name=Store Location=''>Store Location</option>";
$query = "SELECT StoreLocation FROM Stores";
$result = mysql_query($query);
echo "<select name =stores value=''>loaction</Option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[Storelocation]></option>";
}
echo "</select>";
/*while($row = mysql_fetch_array($result))
{
echo "<option value=$row[StoreLocation]></option>";
echo "</select>";
}*/
mysql_close($con);
?>
any help is apreciated thanks in advance
Populating drop down box
Moderator: General Moderators
Re: Populating drop down box
First, to return errors use this:
$result = mysql_query($query) or die(mysql_error()." LINE:".__LINE__);
Second thing:
$nt[Storelocation] should be $nt['Storelocation'] (quotes around "Storelocation")
To see what you have in your variables use:
print_r($nt);
This way you can check if there is anything being returned or if you've misspelled a variable.
E
$result = mysql_query($query) or die(mysql_error()." LINE:".__LINE__);
Second thing:
$nt[Storelocation] should be $nt['Storelocation'] (quotes around "Storelocation")
To see what you have in your variables use:
print_r($nt);
This way you can check if there is anything being returned or if you've misspelled a variable.
E