hostfreak Posted April 21, 2006 Share Posted April 21, 2006 What im trying to do is be able to select the agent name which is $username from the table users but have its value be the id_num. Here is what Im doing:[code]$query = "SELECT id_num FROM users WHERE userlevel = '8'"; $result = mysql_query($query);print "<SELECT name=id_num><option>Choose One</option>"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<option value='$id_num'>$id_num</option>"; } mysql_close($link);print "</SELECT>"; [/code]Im not sure how to exactly call the $username. Last time i tried it, it listed the username logged in for all the options. I guess because i didn't call it as a line or something. Quote Link to comment https://forums.phpfreaks.com/topic/8086-help/ Share on other sites More sharing options...
gizmola Posted April 21, 2006 Share Posted April 21, 2006 [!--quoteo(post=367326:date=Apr 21 2006, 02:27 PM:name=HostFreak)--][div class=\'quotetop\']QUOTE(HostFreak @ Apr 21 2006, 02:27 PM) [snapback]367326[/snapback][/div][div class=\'quotemain\'][!--quotec--]What im trying to do is be able to select the agent name which is $username from the table users but have its value be the id_num. Here is what Im doing:[code]$query = "SELECT id_num FROM users WHERE userlevel = '8'"; $result = mysql_query($query);print "<SELECT name=id_num><option>Choose One</option>"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<option value='$id_num'>$id_num</option>"; } mysql_close($link);print "</SELECT>"; [/code]Im not sure how to exactly call the $username. Last time i tried it, it listed the username logged in for all the options. I guess because i didn't call it as a line or something.[/quote]First off, you can query more than one column in a single query, right?Try this code instead:[code]$query = "SELECT id_num, username FROM users WHERE userlevel = '8'"; $result = mysql_query($query);print "<SELECT name=id_num><option>Choose One</option>"; while ($row = mysql_fetch_assoc($result)) { echo "<option value='{$row['id_num']}'>{$row['username']}</option>"; } mysql_close($link);print "</SELECT>"; [/code] Quote Link to comment https://forums.phpfreaks.com/topic/8086-help/#findComment-29471 Share on other sites More sharing options...
hostfreak Posted April 22, 2006 Author Share Posted April 22, 2006 Worked, thank gizmola. Anyways why I still have this thread open, I have one more question. Is is possible to make a page generate a number say starting at 40,000 and then if clicked 40,001 and so on with php? Thanks once again. Quote Link to comment https://forums.phpfreaks.com/topic/8086-help/#findComment-29624 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.