PDA

View Full Version : Display SQL Results


teamshultz
12-18-2010, 09:53 PM
I'm trying to create a module that will display the members of a particular usergroup in-line.

Here's my current SQL Query:

$results = $db->query_read("SELECT username FROM " . TABLE_PREFIX . "user WHERE usergroupid = 2 ORDER BY username");

Can someone help me display the resulting usernames in-line?

Example:

user1; user2; user3; user4


Possibly relevant: This is all going to be executed in a PHP file. I will not be using any templates.

Thanks for reading.

JoeZ
02-21-2011, 04:38 PM
$users_inline = ""; //establish variable. This is what you will call to retrieve the names.

$results = $db->query_read("SELECT username FROM " . TABLE_PREFIX . "user WHERE usergroupid = 2 ORDER BY username");

while ($selected_users = $db->fetch_array($results)){
$users_inline .= $selected_users['username'] . "<br>"; // the '.=' means it'll add to the variable, rather than replace it.
}


Hope that helps.