Jump to content

Search Results Array - any way to have all results appear in ONE table?


murtz

Recommended Posts

Hi all..

 

Im creating a php page that scripts out all registered members.

 

It all works.. but the table I want the results to appear in repeats for each record!

 

Ive got a screen shot of it below..

 

th.5b82f4e135.jpg

 

Obviously.. it just looks wrong!

 

the code Im using for it is below..

 

<?php
if ($num > 0) { // If it ran OK, display the records.

echo "Currently, There Are $num Registered Members";
}
else
{
echo "There Are No Registered Members";
}
?></span></p>
    
    <?php			
while($row = mysql_fetch_array($result))
		{ 
?>
<table border="1" align="center" cellpadding="10" cellspacing="0" bordercolor="#D6D6D6">
  <tr>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Student ID</p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Full Name</p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Course </p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Email_Address </p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"><span class="style19" style="text-align: left;">Delete Member</span></p></td>
  </tr>
  <tr>
    <td><span class="style20"><?php echo $row["student_id"]; ?></span></td>
    <td><span class="style20"><?php echo $row["full_name"]; ?></span></td>
    <td><span class="style20"><?php echo $row["course"]; ?></span></td>
    <td><span class="style20"><?php echo $row["email_address"]; ?></span></td>
    <td><p class="style20" style="text-align: left;">
      <input type="submit" name="Deletemember" id="Deletemember" value="Delete Member" />
    </p></td>
  </tr>
</table>
<p align="center"> </p>

<?php
   }
       ?>

 

Can anyone see where Im going wrong?

You need to move a few things outside of the while loop.  Here you go...

 

<?php
if ($num > 0) { // If it ran OK, display the records.

echo "Currently, There Are $num Registered Members";
}
else
{
echo "There Are No Registered Members";
}
?></span></p>
  
<table border="1" align="center" cellpadding="10" cellspacing="0" bordercolor="#D6D6D6">
  <tr>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Student ID</p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Full Name</p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Course </p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"> Email_Address </p></td>
    <td height="30" bordercolor="#D6D6D6" bgcolor="#9BFFFF"><p class="style19" style="text-align: left;"><span class="style19" style="text-align: left;">Delete Member</span></p></td>
  </tr>
    <?php			
while($row = mysql_fetch_array($result))
		{ 
?>
  <tr>
    <td><span class="style20"><?php echo $row["student_id"]; ?></span></td>
    <td><span class="style20"><?php echo $row["full_name"]; ?></span></td>
    <td><span class="style20"><?php echo $row["course"]; ?></span></td>
    <td><span class="style20"><?php echo $row["email_address"]; ?></span></td>
    <td><p class="style20" style="text-align: left;">
      <input type="submit" name="Deletemember" id="Deletemember" value="Delete Member" />
    </p></td>
  </tr>
<?php
   }
       ?>
</table>
<p align="center"> </p>

Archived

This topic is now archived and is closed to further replies.

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