link7722 Posted September 6, 2008 Share Posted September 6, 2008 I am using a drop down list which is dynamically populated from mysql succesfully with the following code <select name="user" id="user"> <?php while ($row = mysql_fetch_array($query)) { echo "<option value=\"".$row['id']."\">".$row['username']."\n "; } ?> </select> My problem is that when i use $username = $_POST['user']; to get the result from the list its empty. What am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/122996-cant-get-results-from-dynamically-populated-drop-down-list/ Share on other sites More sharing options...
Fadion Posted September 6, 2008 Share Posted September 6, 2008 Are you sure the list is displaying correctly, as you're missing the closing tag for the < option >: echo "<option value=\"".$row['id']."\">".$row['username']."</option>\n "; } Link to comment https://forums.phpfreaks.com/topic/122996-cant-get-results-from-dynamically-populated-drop-down-list/#findComment-635135 Share on other sites More sharing options...
link7722 Posted September 6, 2008 Author Share Posted September 6, 2008 Although the dropdown list displayed ok, i changed the code to while ($row = mysql_fetch_assoc($query)) { echo "<option>$row[username]</option>"; and everything works ok. Thank you for your help GuiltyGear Link to comment https://forums.phpfreaks.com/topic/122996-cant-get-results-from-dynamically-populated-drop-down-list/#findComment-635268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.