dean7 Posted November 26, 2010 Share Posted November 26, 2010 Hi all, ive got a script witch im wanting to echo all the selected users in a table.. It selects and echos the users but just dosent add on to the table. <?php $themembers = mysql_query("SELECT * FROM users WHERE crew = '$user->crew'"); $ammoutmembers = mysql_num_rows($themembers); ?> <html> <head> <title>Crew Members || SD</title> </head> <body> <?php if ($crewstuff->boss == $username || $crewstuff->coowner == $username || $crewstuff->underboss == $username){ ?> <table width='80%' align='center' class='table' cellpadding='0' cellspacing='0' border='1'> <tr> <td class='header' colspan='3' align='center'>Current Crew Members</td> </tr> <tr> <td class='omg' align='center' width='40%'>Username</td><td class='omg' align='center' width='30%'>Rep</td><td class='omg' width='30%' align='center'>Kick</td> </tr> <?php if ($ammoutmembers != "0"){ while ($member11 = mysql_fetch_object($themembers)){ ?> <tr> <td width='40%'><?php echo("<a href='profile.php?viewuser=$member11->username' target='mainFrame'>$member11->username</a>"); ?></td><td width='30%'><?php echo ("".number_format($member11->rep).""); ?></td><td width='30%'><?php echo("<a href='?action=members&kick=$member11->username'>Kick</a>"); ?></td> </tr> <tr> <td colspan='3' class='omg' align='center'>Any member kicked is logged.</td> </tr> </table> <?php } // $member11 }// $ammoutmembers }elseif ($crewstuff->member == $username){ echo ("Your not being here , without being staff."); } ?> Is there way I can make it so it will be something like this layout: Username | Rep | Kick ---------------------------------- username | 0 | Kick username | 0 | kick For each user thats echoed? Thanks for help given Quote Link to comment Share on other sites More sharing options...
intellix Posted November 26, 2010 Share Posted November 26, 2010 The problem is that within your while loop that iterates through the result set... you have the </table> end tag. You only want to loop this: <tr><td></td><td></td><td></td></tr> Row > cell cell cell You just want to do like: <?php if ($crewstuff->boss == $username || $crewstuff->coowner == $username || $crewstuff->underboss == $username){ ?> <table> <thead> <th>User</th> <th>Rep</th> <th>Kick</th> </thead> <tbody> <?php if ($ammoutmembers != "0"){ while ($member11 = mysql_fetch_object($themembers)){ ?> <tr> <td><?php echo("<a href='profile.php?viewuser=$member11->username' target='mainFrame'>$member11->username</a>"); ?></td> <td><?php echo ("".number_format($member11->rep).""); ?></td> <td><?php echo("<a href='?action=members&kick=$member11->username'>Kick</a>"); ?></td> </tr> <?php } // $member11 }// $ammoutmembers ?> </tbody> </table> <?php }elseif ($crewstuff->member == $username){ echo ("Your not being here , without being staff."); } ?> Quote Link to comment Share on other sites More sharing options...
dean7 Posted November 26, 2010 Author Share Posted November 26, 2010 The problem is that within your while loop that iterates through the result set... you have the </table> end tag. You only want to loop this: <tr><td></td><td></td><td></td></tr> Row > cell cell cell You just want to do like: <?php if ($crewstuff->boss == $username || $crewstuff->coowner == $username || $crewstuff->underboss == $username){ ?> <table> <thead> <th>User</th> <th>Rep</th> <th>Kick</th> </thead> <tbody> <?php if ($ammoutmembers != "0"){ while ($member11 = mysql_fetch_object($themembers)){ ?> <tr> <td><?php echo("<a href='profile.php?viewuser=$member11->username' target='mainFrame'>$member11->username</a>"); ?></td> <td><?php echo ("".number_format($member11->rep).""); ?></td> <td><?php echo("<a href='?action=members&kick=$member11->username'>Kick</a>"); ?></td> </tr> <?php } // $member11 }// $ammoutmembers ?> </tbody> </table> <?php }elseif ($crewstuff->member == $username){ echo ("Your not being here , without being staff."); } ?> Thanks, changed my code and it worked 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.