grahamb314 Posted September 14, 2008 Share Posted September 14, 2008 PHP - Populate a Combo Box from SQL Query Hi all, I have a database with a series of fields. I wish those fields to all be displayed in a drop down box, row by row. Does someone have some sample code to do this, or something better? - I can do this with a table that has 1 field, but not several! Cheers, Graham Link to comment https://forums.phpfreaks.com/topic/124195-solved-php-populate-a-combo-box-from-sql-query/ Share on other sites More sharing options...
unrelenting Posted September 14, 2008 Share Posted September 14, 2008 http://www.phpfreaks.com/forums/index.php/topic,216250.0.html Link to comment https://forums.phpfreaks.com/topic/124195-solved-php-populate-a-combo-box-from-sql-query/#findComment-641237 Share on other sites More sharing options...
grahamb314 Posted September 14, 2008 Author Share Posted September 14, 2008 Thanks for the link: Ive modified what I Had and now have this: But it doesnt display anything in the drop down box!? <form action="delete_show_results.php" method="POST"> <div align="center"> <p> <select name="toDelete"> <?php require_once 'mysql_connect.php'; $allShows = mysqli_query($mysqli, "SELECT * FROM shows"); while ($row = mysqli_fetch_object($allShows)) { echo "<option value=\"<? echo $row->; ?>\"><? echo $row->Gallery; ?></option>"; } ?> </select> </p> <p> <input type="submit" value="Delete"></p> </div> </form> Link to comment https://forums.phpfreaks.com/topic/124195-solved-php-populate-a-combo-box-from-sql-query/#findComment-641248 Share on other sites More sharing options...
unrelenting Posted September 14, 2008 Share Posted September 14, 2008 Try $row['gallery'] and $row['name_of_column'] rather than the $row->Gallery and $row-> Link to comment https://forums.phpfreaks.com/topic/124195-solved-php-populate-a-combo-box-from-sql-query/#findComment-641251 Share on other sites More sharing options...
grahamb314 Posted September 14, 2008 Author Share Posted September 14, 2008 What does $row['gallery'] and $row['name_of_column'] actually do? 'gallery' is from the example. and i dont know what i need to put in there Link to comment https://forums.phpfreaks.com/topic/124195-solved-php-populate-a-combo-box-from-sql-query/#findComment-641318 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.