mysql_fetching problem
Posted: Wed Nov 09, 2005 2:20 pm
i’m attempting to make a drop down list in an html form where the select options are pulled from a field (name) in a mysql database table (properties).
at first i was using a foreach loop but thought while would save a line or two. with this code i get a drop down menu showing the first ‘name’ in the field and then blanks for each other ‘name’ in the field. it’s iterating the correct number of times, just not echoing anything. is mysql_fetch_array the wrong function to use or is it something silly like the wrong query?
Code: Select all
$query = "SELECT name FROM properties";
$result = mysql_query($query, $connection);
// later, inside the form
$i=0;
while($prop = mysql_fetch_array($result)){
echo '<option value="'.$prop[$i].'">'.$prop[$i].'</option>';
$i++;
}