seany123 Posted April 3, 2009 Share Posted April 3, 2009 soz if this is wrong sections... problem im having is its completely missing out the if($member['staff']{echo ETC... and the ($last_active){ echo ETC goes in its place... <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>World Leaders</strong></td> </tr> </table> <br> <table width="54%" border="0" align="left"> <tr> <th width="8%"> <th width="26%"><b>Username</b></td> <th width="16%"><strong>Position</strong> <th width="20%"><strong>Status</strong> </tr> <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `staff`, `banned`, `rm`, `ncolor`, `last_active` from `players` order by `staff` desc limit 50"); while($member = $query->fetchrow()) { if($member['staff'] >= 1) { echo "<td>"; 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 "<td><font color=\"\">".$member['username']."</font></td>"; } else if($member[`staff`] == 1) { echo "<td><font color=\"red\">Forum Moderator</font></td>"; } else if($member[`staff`] == 2) { echo "<td><font color=\"red\">Moderator</font></td>"; } else if($member[`staff`] == 3) { echo "<td><font color=\"red\">Global Moderator</font></td>"; } else if($member[`staff`] == 4) { echo "<td><font color=\"red\">Admin</font></td>"; } else if($member[`staff`] == 5) { echo "<td><font color=\"red\">Owner</font></td>"; } if ($member['last_active'] >= Time()-1200) { echo "<td><font color=\"lime\">Online</font></td>"; } else { echo "<td><font color=\"red\">Offline</font></td>"; } } } ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/ Share on other sites More sharing options...
seany123 Posted April 3, 2009 Author Share Posted April 3, 2009 i have tinkered around with this loads and still cant find a way to make it work... am i being stupid here? Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-800742 Share on other sites More sharing options...
mrMarcus Posted April 3, 2009 Share Posted April 3, 2009 can't say i really understand what you said was your problem in your first post there, but i can tell you that you're missing a closing '}' from your initial 'if($member['staff'] >= 1) {' .. perhaps that's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-800754 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 im not missing a } at the bottom of the code i have } } which covers the top 2 { { Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801240 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 the current problem im having is its missing one of the queries and the online status (last_active) query is moving up look at attachment [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801252 Share on other sites More sharing options...
Showcase Posted April 4, 2009 Share Posted April 4, 2009 else if($member[`staff`] == 1) { echo "<td><font color=\"red\">Forum Moderator</font></td>"; } else if($member[`staff`] == 2) I'm guessing position = staff value. The problem looks like the first if that's checking the staff value is an else if, so it's "else iffing" off of the banned and ncolor checks. Some commenting between those if blocks would make this a bit easier to read and track down. And I don't know what kind of values exist in your database but storing the colors and positions into arrays than simply checking if the value exists in ncolor and staff could knock out a lot of those if statements like this: <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>World Leaders</strong></td> </tr> </table> <br> <table width="54%" border="0" align="left"> <tr> <th width="8%"> <th width="26%"><b>Username</b></td> <th width="16%"><strong>Position</strong> <th width="20%"><strong>Status</strong> </tr> <?php $colors = array("blue","green","yellow","pink","silver"); $positions = array("Forum Moderator","Moderator","Global Moderator","Admin","Owner"); //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `staff`, `banned`, `rm`, `ncolor`, `last_active` from `players` order by `staff` desc limit 50"); while($member = $query->fetchrow()) { if($member['staff'] >= 1) { echo "<td>"; 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'] != NULL) { echo "<font color=\"".$colors[$member['ncolor']]."\">".$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 "<td><font color=\"\">".$member['username']."</font></td>"; } if($member[`staff`] != NULL) { echo "<td><font color=\"red\">".$positions[$member['staff']]."</font></td>"; } if ($member['last_active'] >= Time()-1200) { echo "<td><font color=\"lime\">Online</font></td>"; } else { echo "<td><font color=\"red\">Offline</font></td>"; } } } ?> </table> You might have to change a few things based on the values in your database but something like that should work. Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801261 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 okay so i have changed that to if... i also added a else at the bottom of that set of queries just in case.. but nothing has changed. <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>World Leaders</strong></td> </tr> </table> <br> <table width="54%" border="0" align="left"> <tr> <th width="8%"> <th width="26%"><b>Username</b></td> <th width="16%"><strong>Position</strong> <th width="20%"><strong>Status</strong> </tr> <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `staff`, `banned`, `rm`, `ncolor`, `last_active` from `players` order by `staff` desc limit 50"); while($member = $query->fetchrow()) { //This is to stop people being displayed if their staff is lower than 1. if($member['staff'] >= 1) { echo "<td>"; echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">"; //This displays the username of each person (in different colors. 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 "<td><font color=\"\">".$member['username']."</font></td>"; } //This shows the Position held by the user. if($member[`staff`] == 1) { echo "<td><font color=\"red\">Forum Moderator</font></td>"; } else if($member[`staff`] == 2) { echo "<td><font color=\"red\">Moderator</font></td>"; } else if($member[`staff`] == 3) { echo "<td><font color=\"red\">Global Moderator</font></td>"; } else if($member[`staff`] == 4) { echo "<td><font color=\"red\">Admin</font></td>"; } else if($member[`staff`] == 5) { echo "<td><font color=\"red\">Owner</font></td>"; } else { echo "<td><font color=\"red\">None</font></td>"; } //This shows if the user is on or offline. if ($member['last_active'] >= Time()-1200) { echo "<td><font color=\"lime\">Online</font></td>"; } else { echo "<td><font color=\"red\">Offline</font></td>"; } } } ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801270 Share on other sites More sharing options...
Showcase Posted April 4, 2009 Share Posted April 4, 2009 You're missing "</td>" at the end of all your ncolor check echos. And you're not starting and ending a new <tr> table row at the start and end of each loop. Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801288 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 added the </td>s and i dont really know where to put the <tr> and </tr>s but ive tried adding them and it still hasnt changed anything... <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>World Leaders</strong></td> </tr> </table> <br> <table width="54%" border="0" align="left"> <tr> <th width="8%"> <th width="26%"><b>Username</b></td> <th width="16%"><strong>Position</strong> <th width="20%"><strong>Status</strong> </tr> <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `staff`, `banned`, `rm`, `ncolor`, `last_active` from `players` order by `staff` desc limit 50"); while($member = $query->fetchrow()) { //This is to stop people being displayed if their staff is lower than 1. if($member['staff'] >= 1) { <tr> echo "<td>"; echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">"; //This displays the username of each person (in different colors. if ($member['banned'] >= 1) { echo "<td><b>[b] </b></td>"; echo "td><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>"; } </tr> //This shows the Position held by the user. if($member[`staff`] == 1) { <tr> echo "<td><font color=\"red\">Forum Moderator</font></td>"; } else if($member[`staff`] == 2) { echo "<td><font color=\"red\">Moderator</font></td>"; } else if($member[`staff`] == 3) { echo "<td><font color=\"red\">Global Moderator</font></td>"; } else if($member[`staff`] == 4) { echo "<td><font color=\"red\">Admin</font></td>"; } else if($member[`staff`] == 5) { echo "<td><font color=\"red\">Owner</font></td>"; } else { echo "<td><font color=\"red\">None</font></td>"; } </tr> //This shows if the user is on or offline. if ($member['last_active'] >= Time()-1200) <tr> { echo "<td><font color=\"lime\">Online</font></td>"; } else { echo "<td><font color=\"red\">Offline</font></td>"; } </tr> } } ?> </table> just realised the <tr> tags need to be in the echos lol Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801294 Share on other sites More sharing options...
Showcase Posted April 4, 2009 Share Posted April 4, 2009 Looked through your code and saw what seemed to be problems in your html. This may not fix it, but try it and see what happens. Here's the entire adjusted code: <table width="650" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000"> <tr> <td align="center" class="style5"><strong>World Leaders</strong></td> </tr> </table> <br> <table width="54%" border="0" align="left"> <tr> <th width="8%" /> <th width="26%"><b>Username</b></th> <th width="16%"><strong>Position</strong></th> <th width="20%"><strong>Status</strong></th> </tr> <?php //Select all members ordered by level (highest first, members table also doubles as rankings table) $query = $db->execute("select `id`, `username`, `staff`, `banned`, `rm`, `ncolor`, `last_active` from `players` order by `staff` desc limit 50"); while($member = $query->fetchrow()) { //This is to stop people being displayed if their staff is lower than 1. if($member['staff'] >= 1) { echo "<tr>"; echo "<td />"; echo "<td><a href=\"profile.php?id=" . $member['username'] . "\">"; //This displays the username of each person (in different colors. 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></td>"; } else if($member['ncolor'] == 2) { echo "<font color=\"green\">".$member['username']."</font></td>"; } else if($member['ncolor'] == 3) { echo "<font color=\"yellow\">".$member['username']."</font></td>"; } else if($member['ncolor'] == 4) { echo "<font color=\"pink\">".$member['username']."</font></td>"; } else if($member['ncolor'] == 5) { echo "<font color=\"silver\">".$member['username']."</font></td>"; } else if($member['staff'] >= 1) { echo "<font color=\"gold\">".$member['username']."</font></td>"; } else if($member['rm'] >= 1) { echo "<font color=\"red\">".$member['username']."</font></td>"; } else { echo "<td><font color=\"\">".$member['username']."</font></td>"; } //This shows the Position held by the user. if($member[`staff`] == 1) { echo "<td><font color=\"red\">Forum Moderator</font></td>"; } else if($member[`staff`] == 2) { echo "<td><font color=\"red\">Moderator</font></td>"; } else if($member[`staff`] == 3) { echo "<td><font color=\"red\">Global Moderator</font></td>"; } else if($member[`staff`] == 4) { echo "<td><font color=\"red\">Admin</font></td>"; } else if($member[`staff`] == 5) { echo "<td><font color=\"red\">Owner</font></td>"; } else { echo "<td><font color=\"red\">None</font></td>"; } //This shows if the user is on or offline. 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>"; } } ?> </table> You were missing a lot of closing tags. The new table row tags are in there as well. Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801301 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 thankyou for spending your time adjusting the code.. sadly it hasnt made a difference. Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801314 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 ive tried tinkering around with it but still no better off Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801404 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 okay the problem is with the ==. it displays what it correctly if i just used 1 = if($member[`staff`] == 1) { echo "<td><font color=\"\">Forum Moderator</font>"; } else if($member[`staff`] == 2) { echo "<td><font color=\"\">Moderator</font>"; } else if($member[`staff`] == 3) { echo "<td><font color=\"\">Global Moderator</font>"; } else if($member[`staff`] == 4) { echo "<td><font color=\"\">Admin</font></td>"; } else if($member[`staff`] == 5) { echo "<td><font color=\"\">Owner</font>"; } but obviously if i just used 1 = then it would say "Forum moderator" for everyone even people who have higher ['staff']... Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801409 Share on other sites More sharing options...
seany123 Posted April 4, 2009 Author Share Posted April 4, 2009 I have found the error... i was using `` instead of '' thanks for all help Quote Link to comment https://forums.phpfreaks.com/topic/152412-solved-table-problems/#findComment-801410 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.