PDA

View Full Version : Query Question


CoolHand_79
06-08-2006, 05:37 PM
How would I write the PHP code that would query a specific usergroup and list the names of the users in html?

Thanks,

Luke

Can anyone show a working example of this code? I would really appreciate it.

Thanks,

Luke

sebbe
06-11-2006, 09:38 AM
$dbh=mysql_connect ("localhost", "username", "password") or die(mysql_error());
mysql_select_db ("forum_database");

$query = "SELECT username FROM user WHERE usergroupid = 'XX' ORDER BY username ASC";
$result = mysql_query($query) or die(mysql_error());

while(list($username) = mysql_fetch_array($result))
{
echo $username . "<br />";
}
mysql_close();


Just replace XX in the query with your desired usergroupid!