title: Create page navigation using php
body: <p>I am having some issues trying to create page navigation using php,</p>
  
  <p>I have variable called $PageNo that I can navigate through using using next prev links -1 or +1.</p>
  
  <p>eg. </p>
  
  <pre><code>echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=".($PageNo+1)."'&gt;Next&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=".($PageNo-1)."'&gt;Prev&lt;/a&gt;";
  </code></pre>
  
  <p>but aswell as this is want to display direct links to the pages so i have a navigation like so</p>
  
  <p>PREV 1 2 3 4 NEXT</p>
  
  <pre><code>echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=".($PageNo+1)."'&gt;Next&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=1'&gt;1&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=2'&gt;2&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=3'&gt;3&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=4'&gt;4&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=".($PageNo-1)."'&gt;Prev&lt;/a&gt;";
  </code></pre>
  
  <p>If I know the total number of product pages is 4 how would you generate the links to give</p>
  
  <pre><code>echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=1'&gt;1&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=2'&gt;2&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=3'&gt;3&lt;/a&gt;";
  echo "&lt;a href='http://".$_SERVER["HTTP_HOST"]."/product.php?page=4'&gt;4&lt;/a&gt;";
  </code></pre>
  
  <p>Any help would be great.</p>