PHP Programming > Beginners - Learning PHP

making an active roster list

(1/2) > >>

Onarous:
Hi,

  I'm trying to take the different groups from a database (phpbb3). and create a list for each of the clans sections.

Admin group_id = 5
staff group_id = 12
members group_id = 16

I can get it to take the info from one group, but trying to take it from 2 groups I get no output (white page).  If you could give me pointers on where i'm going wrong.


--- PHP Code: ---// query for clan admins
$resulta = mysql_query("SELECT username FROM phpbb_users WHERE group_id='5'");
while ($row1 = mysql_fetch_array($resulta))
{
list($username) = $row1;
echo "[UKE]$username, ";
}
<br>
--- End code ---


if I add in another but chaning the $resulta and $row1 i get nothing

Noodles:
Your mysql query says take it from group 5 only try adding this to the end of the query.


--- PHP Code: ---group_id='5' AND group_id='12'
--- End code ---

Onarous:
yea that brings them all out in one line, but with me having a few special groups I need to seperate them on the roster.  hence the need for different queries

Noodles:
Separate queries or use php


PHP way

--- PHP Code: ---
// query for clan admins
$resulta = mysql_query("SELECT username,group_id FROM phpbb_users WHERE group_id='5' AND group_id='12'  AND group_id='16' ");
while ($row1 = mysql_fetch_array($resulta)) {
list($username) = $row1;

if($row1['group_id']=='5' ){
echo "[UKE]$username, ";
} else 
if($row1['group_id']=='12' ){
echo "[UKE]$username, ";
} else
if($row1['group_id']=='16' ){ 
echo "[UKE]$username, ";
    }
}
<br>

--- End code ---



Separtate queries

--- PHP Code: ---
// query for clan admins
$resulta = mysql_query("SELECT username FROM phpbb_users WHERE group_id='5'");
while ($row1 = mysql_fetch_array($resulta)) {
list($username) = $row1;
echo "[UKE]$username, ";
}
<br>

--- End code ---



--- PHP Code: ---
// query for clan admins
$resulta = mysql_query("SELECT username FROM phpbb_users WHERE group_id='12'");
while ($row1 = mysql_fetch_array($resulta)) {
list($username) = $row1;
echo "[UKE]$username, ";
}
<br>

--- End code ---



--- PHP Code: ---
// query for clan admins
$resulta = mysql_query("SELECT username FROM phpbb_users WHERE group_id='16'");
while ($row1 = mysql_fetch_array($resulta)) {
list($username) = $row1;
echo "[UKE]$username, ";
}
<br>

--- End code ---

Onarous:
tryed both way, and was having problems, took out the <br> and seemed to output info on my first file.  So working on trying to get it to look right.

Navigation

[0] Message Index

[#] Next page

Go to full version