Jump to content

[SOLVED] help with tables.


seany123

Recommended Posts

okay i currently have this code:

 

table width="54%" border="0" align="left">
<tr>
  <th width="8%"> 
  <th width="14%">Rank 
  <th width="26%"><b>Username</b>
      </td>
  <th width="16%"><strong>Level</strong>
  <th width="20%"><strong>Money</strong>
  <th width="16%">Status</tr>
<?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` 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'] . "\">";
	echo $member['username'];
   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 change the $username bit so it has this...

heres the code i want added...

 

<?php 
    if ($member['banned'] == 1)
    {
    echo "<b>[b] </b>"; echo "<STRIKE>" .$member['username']. "</STRIKE>";
    }
    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>";	
}
    ?>

 

but everytime i try and put it in i just get a white page...

 

 

please help me out if you can!!

 

Link to comment
Share on other sites

can anyone see anything wrong with this these lines...

 

echo "<font color=\"blue\">".$member['username']."</font>";

There is nothing wrong with those lines other than the fact that you are using very old styling methods.

Link to comment
Share on other sites

firstly i would like to apologise for my code not being very clean...

 

<?php
include("lib.php");
define("PAGENAME", "Hall Of Fame");
$player = check_user($secret_key, $db);
$i = 1;
include("templates/private_header.php");
?>

<style type="text/css">
<!--
body, td, th {
   color: #FFFFFF;
}
body {
   background-color: #000000;
}
a:link {
   color: #FF0000;
}
a:visited {
   color: #FF0000;
}
a:hover {
   color: #666666;
}
a:active {
   color: #FF0000;
}
.style5 {color: #FFFFFF}
-->
</style>
<table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
  <tr>
    <td align="center" class="style5"><strong>Hall Of Fame </strong></td>
  </tr>
</table>
<table width="660" border="0">
  <tr>
    <td width="90"><div align="center"><a href="levelhof.php">Level</a></div></td>
    <td width="90"><div align="center"><a href="moneyhof.php">Money</a></div></td>
    <td width="90"><div align="center"><a href="bankhof.php">Bank</a></div></td>
    <td width="90"><div align="center"><a href="pointshof.php">Points</a></div></td>
    <td width="90"><div align="center"><a href="strengthhof.php">Strength</a></div></td>
    <td width="90"><div align="center"><a href="defencehof.php">Defence</a></div></td>
    <td width="90"><div align="center"><a href="speedhof.php">Speed</a></div></td>
  </tr>
</table>
<br>
<table width="54%" border="0" align="left">
<tr>
  <th width="8%"> 
  <th width="14%">Rank 
  <th width="26%"><b>Username</b>
      </td>
  <th width="16%"><strong>Level</strong>
  <th width="20%"><strong>Money</strong>
  <th width="16%">Status</tr>
<?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'] . "\">";
    <?php 
if ($member['banned'] == 1)
    {
    echo "<td><b>[b] </b>"; 
    echo "<STRIKE>" .$member['username']. "</STRIKE></td>";
    }
    else if ($member['ncolor'] == 1)
    {
    echo "<td><font color=\"blue\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 2)
    {
    echo "<td><font color=\"green\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 3)
    {
    echo "<td><font color=\"yellow\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 4)
    {
    echo "<td><font color=\"pink\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 5)
    {
    echo "<td><font color=\"silver\">".$member['username']."</font></td>";
    }
    else if($member['staff'] >= 1)
    { 
    echo "<td><font color=\"gold\">".$member['username']."</font></td>";
    }
    else if($member['rm'] >= 1)
    {
    echo "<td><font color=\"red\">".$member['username']."</font></td>";
    }
else
{
echo "<td><font color=\"\">".$member['username']."</font></td>";	
}
   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>

<div align="center">
</div>

Link to comment
Share on other sites

i just debugged the code a little and now its no longer a white page however the tables arnt lining up anymore.

 

<?php
include("lib.php");
define("PAGENAME", "Hall Of Fame");
$player = check_user($secret_key, $db);
$i = 1;
include("templates/private_header.php");
?>

<style type="text/css">
<!--
body, td, th {
   color: #FFFFFF;
}
body {
   background-color: #000000;
}
a:link {
   color: #FF0000;
}
a:visited {
   color: #FF0000;
}
a:hover {
   color: #666666;
}
a:active {
   color: #FF0000;
}
.style5 {color: #FFFFFF}
-->
</style>
<table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
  <tr>
    <td align="center" class="style5"><strong>Hall Of Fame </strong></td>
  </tr>
</table>
<table width="660" border="0">
  <tr>
    <td width="90"><div align="center"><a href="levelhof.php">Level</a></div></td>
    <td width="90"><div align="center"><a href="moneyhof.php">Money</a></div></td>
    <td width="90"><div align="center"><a href="bankhof.php">Bank</a></div></td>
    <td width="90"><div align="center"><a href="pointshof.php">Points</a></div></td>
    <td width="90"><div align="center"><a href="strengthhof.php">Strength</a></div></td>
    <td width="90"><div align="center"><a href="defencehof.php">Defence</a></div></td>
    <td width="90"><div align="center"><a href="speedhof.php">Speed</a></div></td>
  </tr>
</table>
<br>
<table width="54%" border="0" align="left">
<tr>
  <th width="8%"> 
  <th width="14%">Rank 
  <th width="26%"><b>Username</b>
      </td>
  <th width="16%"><strong>Level</strong>
  <th width="20%"><strong>Money</strong>
  <th width="16%">Status</tr>
<?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 "<td><b>[b] </b>"; 
    echo "<STRIKE>" .$member['username']. "</STRIKE></td>";
    }
    else if ($member['ncolor'] == 1)
    {
    echo "<td><font color=\"blue\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 2)
    {
    echo "<td><font color=\"green\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 3)
    {
    echo "<td><font color=\"yellow\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 4)
    {
    echo "<td><font color=\"pink\">".$member['username']."</font></td>";
    }
    else if($member['ncolor'] == 5)
    {
    echo "<td><font color=\"silver\">".$member['username']."</font></td>";
    }
    else if($member['staff'] >= 1)
    { 
    echo "<td><font color=\"gold\">".$member['username']."</font></td>";
    }
    else if($member['rm'] >= 1)
    {
    echo "<td><font color=\"red\">".$member['username']."</font></td>";
    }
    else
    {
    echo "<td><font color=\"\">".$member['username']."</font></td>";	
    }
    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>

<div align="center">
</div>

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.