I don't know if this is what pagination with PHP/MySQL is but I'm hoping I get my problem out clearly.
I already created the code to pull out the most recent news articles from my database:
$display_articles = mysql_query("SELECT id,date_FORMAT(date,'%m/%d/%Y at %l:%i:%s %p') AS date, title, teaser, news FROM news ORDER BY date DESC")
or die ("MySQL Error");
if (mysql_num_rows($display_articles) > 0)
{
while ($row = mysql_fetch_array($display_articles))
{
$id = $row ["id"];
$date = $row ["date"];
$title = $row ["title"];
$teaser = $row ["teaser"];
$news = $row ["news"];
echo "<p id=\"listnewsTITLE\"><b><a href=\"news.php?id=$id\" class=\"bodynav\">$title</a></b><BR>Posted On $date<BR>$teaser</p>";
}
}
What this does is it lists all the articles in the database, with the newest on top. I want to only show 20 articles at a time, and have a link all the way on the bottom that shows the next 20 articles ON THE SAME PAGE, without affecting any other sql queries on the other of the page. How would I go on about setting this up?