Pagination links on top of the page, before actual script
<p>I have a simple navigation php script which works ok.
The only problem is that I need to find a way to display the pagination links on top of the page instead of the bottom. 
So for me a newb, it seems impossible since I have to show the pagination links before the actual navigation variables are being declared.</p>

<p>Can this be done?</p>

<p>Here is the script:</p>

<pre><code>&lt;?
$numrows = '600';
$rowsperpage = 20;
$totalpages = ceil($numrows / $rowsperpage); 
if ($currentpage &gt; $totalpages){ $currentpage = $totalpages; } 
if ($currentpage &lt; 1){ $currentpage = 1; } 
$offset = ($currentpage - 1) * $rowsperpage; 

HERE I query the data from the table and basically fill in the page.

Now starts the pagination links:

$range = 3;
if ($currentpage &gt; 1) {  
    echo '&lt;a href="'.$site_current.'/'.$slug.'/"&gt;First&lt;/a&gt;'; 
}
$prevpage = $currentpage - 1;   

echo '&lt;a href="'.$site_current.'/'.$slug.'/'.$prevpage.'/"&gt;Previous&lt;/a&gt;';

for ($x = ($currentpage - $range); $x &lt; (($currentpage + $range) + 1); $x++) {   
    if (($x &gt; 0) &amp;&amp; ($x &lt;= $totalpages)) {      
        if($x == $currentpage){ 
            echo '&lt;span class="current"&gt;'.$x.'&lt;/span&gt;'; 
        } else { 

            echo '&lt;a href="'.$site_current.'/'.$slug.'/'.$x.'/"&gt;'.$x.'&lt;/a&gt;';

        } 
    } 
}

if ($currentpage != $totalpages){  
    $nextpage = $currentpage + 1;    
    echo '&lt;a href="'.$site_current.'/'.$slug.'/'.$nextpage.'/"&gt;Next&lt;/a&gt;';   
    echo '&lt;a href="'.$site_current.'/'.$slug.'/'.$totalpages.'/"&gt;Last&lt;/a&gt;'; 
}
?&gt;
</code></pre>
