samuvk Posted March 14, 2016 Share Posted March 14, 2016 I would like to fill a combobox from my data in a table of my postgresql database.Here is my code: but I'm getting the combobox empty. <html> <body> <select> <?php $db = pg_connect('host=localhost dbname=test user=myusername password=mypassword') or die ("Could not connect to DB"); $sql = pg_query(sprintf("SELECT City FROM Cities")); while ($row = pg_fetch_assoc($sql)) { echo "<option value=$row[City]>$row[City]</option>"; } pg_close($db); ?> </select> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/300994-how-to-fill-a-combobox-in-php-from-postgresql/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.