Jump to content

echoing php in a table


dean7

Recommended Posts

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 :D

Link to comment
Share on other sites

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.");
}
?>

Link to comment
Share on other sites

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 :)

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.