PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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).
$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++;
}
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?