daveh33 Posted October 21, 2007 Share Posted October 21, 2007 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>"; } Link to comment https://forums.phpfreaks.com/topic/74239-solved-duplicate-heading-on-table-in-while-statement/ Share on other sites More sharing options...
pocobueno1388 Posted October 21, 2007 Share Posted October 21, 2007 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>"; } ?> Link to comment https://forums.phpfreaks.com/topic/74239-solved-duplicate-heading-on-table-in-while-statement/#findComment-375022 Share on other sites More sharing options...
daveh33 Posted October 21, 2007 Author Share Posted October 21, 2007 Works perfectly, thank you Link to comment https://forums.phpfreaks.com/topic/74239-solved-duplicate-heading-on-table-in-while-statement/#findComment-375023 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.