Struggling with pagination implementation
<p>I've partially developed my pagination implementation, but I have an issue.</p>

<p>I want the pagination to look like this:</p>

<pre><code>Page 3 | Page 4 | Page 5
</code></pre>

<p>The middle link in the pagination is the currently selected page. If the page is 0 the currently selected page is the first link. If the page is not 0 the currently selected page is the second link. If the page is the last page the currently selected page is the 3rd link.</p>

<p>So far my implementation highlights the current page, but does not make the current page the center link. Also, when it gets to the last page, it adds 2 additional pages to the pagination that don't exist.</p>

<pre><code>&lt;?php for($i=0; $i &lt;= $pages &amp;&amp; $i &lt; 3; $i++) : ?&gt;
    &lt;li &lt;?php echo ($page == $i + $page) ? 'class="current-page"' : '' ?&gt;&gt;&lt;a href="category.php?category=&lt;?php echo $category-&gt;category ?&gt;&amp;page=&lt;?php echo $page + $i ?&gt;"&gt;&lt;?php echo $page + $i ?&gt;&lt;/a&gt;&lt;/li&gt;
&lt;?php endfor; ?&gt;
</code></pre>

<p>Any advice?</p>
