Jump to content

Archived

This topic is now archived and is closed to further replies.

hostfreak

help

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.

Share this post


Link to post
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]

Share this post


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

Share this post


Link to post
Share on other sites

×

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.