title: Pagination Problem [PHP]
body: <p>So I'm doing this in PHP but it is a logic issue so I'll try to write it as generically as possible.</p>
  
  <p>To start here's how this pagination script works:</p>
  
  <ol>
  <li>for (<em>draw first three pages links</em>)</li>
  <li>if (<em>draw ellipsis (...) if there are pages between #1's pages and #3's pages</em>)</li>
  <li>for (<em>draw current page and two pages on each side of it links</em>)</li>
  <li>if (<em>draw elipsis (...) if there are pages between #3's pages and #5's pages</em>)</li>
  <li>for (<em>draw final three pages links</em>)</li>
  </ol>
  
  <p>The problem is that when there are low amounts of pages (I noticed this when the page count was at 10) there should be an ellipsis but none is drawn.</p>
  
  <p>Onto the code:</p>
  
  <pre><code>$page_count = 10; //in actual code this is set properly
  $current_page = 1; //in actual code this is set properly
  
  for ($i = 1;$i &lt;= 3;$i++)
  {
      if ($page_count &gt;= $i)
          echo $i;
  }
  
  if ($page_count &gt; 3 &amp;&amp; $current_page &gt;= 7)
      echo "...";
  
  for ($i = $current_page - 2;$i &lt;= current_page + 2;$i++)
  {
      if ($i &gt; 3 &amp;&amp; $i &lt; $page_count - 2)
          echo $i;
  }
  
  if ($page_count &gt; 13 &amp;&amp; $current_page &lt; $page_count - 5)
      echo "...";
  
  for ($i = $page_count - 2;$i &lt;= $page_count;$i++)
  {
      if ($page_count &gt; 3)
          echo $i;
  }
  </code></pre>
  
  <p>So I figure the best idea would to be to modify one of the two ellipsis if statements to include a case like this, however I've tried and am stumped.</p>
  
  <p>Also please note that I condensed this code for readability sake so please don't give tips like "those for loops are ineffective because they will recalculate current_page - 2 for each iteration" because I know :)</p>
  
  <hr>
  
  <p>For those whom want to see a breakdown of how this logic currently works, here is example output ( modified ) with iterating $page_count and $current_page. 
  <a href="http://rafb.net/p/TNa56h71.html" rel="nofollow noreferrer">http://rafb.net/p/TNa56h71.html</a></p>