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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.