PHP function after the last mysql value of table
<p>I want to call a function <code>printPager($max_pages,$pg);</code> to show up after the last value in the table. I've failed with inserting exit() and end().</p>

<pre><code>&lt;?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 "&lt;tr&gt;&lt;td&gt;&lt;h2&gt;&lt;a href=\"viewArticle.php?id=" . $post['ID'] . "\"&gt;" . $post['Title'] . "&lt;/a&gt; by " . $post['Author'] .  "&lt;/h2&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=\"2\"&gt;" . $post['Summary'] . "&lt;/td&gt;&lt;td&gt;"  . $post['Date'] . "&lt;/td&gt;&lt;/tr&gt;";
        echo exit($query);
        printPager($max_pages,$pg);
    }
}
?&gt;
</code></pre>
