Phpnewbie23 Posted January 15, 2009 Share Posted January 15, 2009 i would like to populate a combo box with some database values. Then display them in a table and i was wondering how to do this. Cheers Link to comment https://forums.phpfreaks.com/topic/140953-populate-a-comobo-box/ Share on other sites More sharing options...
chester Posted January 15, 2009 Share Posted January 15, 2009 do you mean something like this? echo "<select name=\"set_user".$i."\">"; echo "<option value=\"0\">-"; $result1 = mysql_query("SELECT username, userid FROM users ORDER BY username DESC"); $num_rows1 = mysql_numrows($result1); for($k=0; $k<$num_rows1; $k++){ $username = mysql_result($result1,$k,"username"); $userid = mysql_result($result1, $k, "userid"); echo "<option value=\"$userid\">$username"; } echo "</select></td>"; } Link to comment https://forums.phpfreaks.com/topic/140953-populate-a-comobo-box/#findComment-737763 Share on other sites More sharing options...
nadeemshafi9 Posted January 15, 2009 Share Posted January 15, 2009 <?php echo "<select name=\"set_user\">"; $users_rs = mysql_query("SELECT * FROM users ORDER BY username DESC"); echo "<option value=\"\">Select a user</option>"; while($user = mysql_fetch_array($result)){ echo "<option value=\"".$user['userid']."\">".$user['username']."</option>"; } echo "</select>"; ?> Link to comment https://forums.phpfreaks.com/topic/140953-populate-a-comobo-box/#findComment-737767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.