What is the best way to display all rows of a table? Here is one way I thought up, but it sucks for a number of reasons:
$files_query1 = "SELECT * FROM `home` WHERE `id` > '0' ;";
$files_result1 = @mysql_query($files_query1);
$number = @mysql_num_rows($files_result1);
<?php;
for ($i=1; $i<=$number; $i++){
$files_query = "SELECT * FROM `home` WHERE `id` = '".$i."' ;";
$files_result = @mysql_query($files_query);
$author = mysql_result($files_result,"author","author");
$title = mysql_result($files_result,"title","title");
$date = mysql_result($files_result,"date","date");
$message = mysql_result($files_result,"message","message");
$query = "SELECT * FROM `users` WHERE `username`='".$author."'";
$result = mysql_query($query);
$authorurl = @mysql_result($result,"authorurl","authorurl");
echo "
<h1>Posted ".$date." By <a href='".$authorurl."'>".$author."</a></h1>
<h2>".$title."</h2><br /><p>".$message."</p><br /><br />";
}
?>
This works in the most basic of circumstances. However, I don’t like it for the following reasons:
I want to display the most recent entry first. Using this loop system, it displays last.
Since the content is dynamic, I want to be able to delete entire entries. Yet again, the loop system fails if a single row is missing (as in, the “id” number jumps any: 1,2,3,5,6,7, etc).
What method would you suggest for this sort of thing?