Use a variable to store the page number requested and modify your SQL query to pull up results in that range. So at the top of your code add the following:
$page = $_GET['page'];
// you may want to use regular expressions to check if $page is really a number
$pagelimit = 10; // in case you want to change the # of articles per page in the future
Change the end of your SQL query to this:
$q = "... ORDER BY date_posted DESC LIMIT " . (($page - 1) * $pagelimit) . ",{$pagelimit}";
So if $page is 1, then we are setting the LIMIT range to 0,10 (start at record 0, pull up 10 records). If $page is 2, then LIMIT is 10,10 (start at record 10, pull up 10 records).
In order to find out how many total records you have you can use COUNT in SQL...
$q = "Select COUNT(*) AS numrecords FROM rms_blog_article INNER JOIN rms_blog_categories ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)AND artchild='0'";
$result = $database->query($q);
$row = mysql_fetch_assoc ($result);
$numrecords = $row['numrecords'];
$numpages = ceil ($numrecords / $pagelimit);
Now you can use $page and the $numpages variable to find out whether there is a "prev" and/or a "next" page...
if ($page > 1) {
// Code to print the prev page link
print "<a href=\"blog.php?page=" . ($page - 1) . "\">Previous Page</a>";
}
if ($page < $numpages) {
// Code to print the next page link
print "<a href=\"blog.php?page=" . ($page + 1) . "\">Next Page</a>";
}