Jump to content

[SOLVED] more table help.


seany123

Recommended Posts

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)

Link to comment
https://forums.phpfreaks.com/topic/152398-solved-more-table-help/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.