Jump to content

help


hostfreak

Recommended Posts

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.
Link to comment
Share on other sites

[!--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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.