I want to call a function printPager($max_pages,$pg); to show up after the last value in the table. I've failed with inserting exit() and end().
<?php
function catPosts($id) {
$id = (int) $id;
$pgsize=2;
$pg=(is_numeric($_GET["p"]) ? $_GET["p"] : 1);
$start=($pg-1)*$pgsize;
$img_total=mysql_query("SELECT COUNT(1) FROM posts WHERE SubcategoryID = '$id'");
$img_total=mysql_fetch_row($img_total);
$img_total=$img_total[0];
$max_pages=$img_total / $pgsize;
$max_pages=ceil($img_total/$pgsize);
$query = mysql_query("SELECT * FROM posts WHERE SubcategoryID = '$id' LIMIT $start, $pgsize");
while($post = mysql_fetch_array($query)) {
echo "<tr><td><h2><a href=\"viewArticle.php?id=" . $post['ID'] . "\">" . $post['Title'] . "</a> by " . $post['Author'] . "</h2></td></tr><tr><td colspan=\"2\">" . $post['Summary'] . "</td><td>" . $post['Date'] . "</td></tr>";
echo exit($query);
printPager($max_pages,$pg);
}
}
?>