Jump to content

[SOLVED] duplicate heading on table in while statement


daveh33

Recommended Posts

My code is below - can someone please tell me what I need to do so it doesn't duplicate the heading for every record

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$url = $row['url'];
echo "	<table border=\"1\">
<tr><th><p align=\"center\">Title</th>
<th><p align=\"center\">Description</th>
<th><p align=\"center\">Status</th>
	<th><p align=\"center\">Modify</th>
		<th><p align=\"center\">Delete</th>
 </tr><tr><td><p align=\"center\">$title</td>
<td><p align=\"center\">$description</td>
<td><p align=\"center\">$status</td>
<td><p align=\"center\"><a href=\"edit.php?id=$id\"><img src=\"../edit.gif\" border=\"0\"></a></td>
<td><p align=\"center\"><a href=\"delete.php?id=$id\"><img src=\"../delete.gif\" border=\"0\"></a></td>";
}

Just take it out of the while loop

 

<?php


echo "<table border=\"1\">
<tr><th><p align=\"center\">Title</th>
<th><p align=\"center\">Description</th>
<th><p align=\"center\">Status</th>
<th><p align=\"center\">Modify</th>
<th><p align=\"center\">Delete</th>";

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$url = $row['url'];

echo "</tr><tr><td><p align=\"center\">$title</td>
<td><p align=\"center\">$description</td>
<td><p align=\"center\">$status</td>
<td><p align=\"center\"><a href=\"edit.php?id=$id\"><img src=\"../edit.gif\" border=\"0\"></a></td>
<td><p align=\"center\"><a href=\"delete.php?id=$id\"><img src=\"../delete.gif\" border=\"0\"></a></td>";
}

?>

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.