Jump to content


Photo

help


  • Please log in to reply
2 replies to this topic

#1 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 21 April 2006 - 09:27 PM

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:

$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>"; 

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.

#2 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,664 posts
  • LocationLos Angeles, CA USA

Posted 21 April 2006 - 10:02 PM

[!--quoteo(post=367326:date=Apr 21 2006, 02:27 PM:name=HostFreak)--][div class=\'quotetop\']QUOTE(HostFreak @ Apr 21 2006, 02:27 PM) View Post[/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:

$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>"; 

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:

$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>"; 



#3 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 22 April 2006 - 05:23 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users