PHP Pagination Problem
<p>I'm having a problem with my PHP pagination for a project.</p>

<p>It almost works but it doesn't seem to display the numbers correctly.</p>

<p>I want only 6 more page numbers to display after the selected and one before;
(also if you are on page one display <strong>7 after</strong>)</p>

<p><strong>For example:</strong></p>

<p>If on Page 1: <strong>1</strong>/2/3/4/5/6/7/8</p>

<p>If on Page 2: 1/<strong>2</strong>/3/4/5/6/7/8</p>

<p>If on Page 5: 4/<strong>5</strong>/6/7/8/9/10/11</p>

<p>If on Page 10: 9/<strong>10</strong>/11/12/13/14/15/16</p>

<p><strong>This is my code so far...</strong></p>

<pre><code>if($page == ceil($NumOfPages) &amp;&amp; $page != 1){
    for($i = 1; $i &lt;= ceil($NumOfPages)-1; $i++){
    if($i &gt; 0){
        echo "&lt;a href=\"/{$i}\"&gt;{$i}&lt;/a&gt;";
    }
    }
}
if ($page == ceil($NumOfPages) ) {
    $startPage = $page;
}else{
    $startPage = 1;
}
for ($i = $startPage; $i &lt;= $page+6; $i++){
        if ($i &lt;= ceil($NumOfPages)){
            if($i == $page) {
                echo "&lt;a href='/page/$i/' title='View movies page $i' id='pagelisel'&gt;$i&lt;/a&gt; ";
            }else{
                echo "&lt;a href='/page/$i/' title='View movies page $i' id='pageli'&gt;$i&lt;/a&gt; ";
            }
        }
}
</code></pre>

<p>Any help would be greatly appreciated,</p>

<p>Thanks!</p>
