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 Quote Link to comment 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>"; } Quote Link to comment 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>"; ?> Quote Link to comment 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.