seany123 Posted April 3, 2009 Share Posted April 3, 2009 i dont know if this is the right section so im sorry if its not... i have a table which shows a "hall of fame" basically showing the best members using their database values... what i wanna do is only show members in a table if they have a certain value in there database table... here is what i have already <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `level`, `money`, `last_active`, `banned`, `staff`, `rm`, `ncolor` from `players` order by `level` desc limit 50"); while($member = $query->fetchrow()) { echo "<td>"; echo "<td>" . number_format($i++) . "</td>\n"; echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">"; if ($member['banned'] >= 1) { echo "<b>[b] </b>"; echo "<STRIKE>" .$member['username']. "</STRIKE></td>"; } else if ($member['ncolor'] == 1) { echo "<font color=\"blue\">".$member['username']."</font>"; } else if($member['ncolor'] == 2) { echo "<font color=\"green\">".$member['username']."</font>"; } else if($member['ncolor'] == 3) { echo "<font color=\"yellow\">".$member['username']."</font>"; } else if($member['ncolor'] == 4) { echo "<font color=\"pink\">".$member['username']."</font>"; } else if($member['ncolor'] == 5) { echo "<font color=\"silver\">".$member['username']."</font>"; } else if($member['staff'] >= 1) { echo "<font color=\"gold\">".$member['username']."</font>"; } else if($member['rm'] >= 1) { echo "<font color=\"red\">".$member['username']."</font>"; } else { echo "<font color=\"\">".$member['username']."</font>"; } echo "<td>" . number_format($member['level']) . "</td>\n"; echo "<td>$" . number_format($member['money']) . "</td>\n"; if ($member['last_active'] >= Time()-1200) { echo "<td><font color=\"lime\">Online</font></td>"; } else { echo "<td><font color=\"red\">Offline</font></td>"; } echo "</tr>\n"; } ?> </table> i want to restrict it to members who only have ($city == 1) Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted April 3, 2009 Share Posted April 3, 2009 try... <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `level`, `money`, `last_active`, `banned`, `staff`, `rm`, `ncolor` from `players` order by `level` desc limit 50"); while($member = $query->fetchrow()) { if($member['city'] == 1) { echo "<table>"; echo "<tr>"; echo "<td>"; echo "Player: " . $member['username']; echo "</td>"; echo "</tr>"; echo "</table>"; } } Regards, ACE EDIT: lol you editted it while I replied. Just throw the if() statement in the while() like in my example and that should work fine. Quote Link to comment Share on other sites More sharing options...
seany123 Posted April 3, 2009 Author Share Posted April 3, 2009 i had to add it into the query but yes that worked thanks for the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.