title: Pagination Prev - Next Increment
body: <p>i create a php news system, but i have a problem:</p>
  
  <pre><code>&lt;?php
  include('config.php');
  if( isset( $_GET["page"]) ) $PAGE=$_GET["page"]; else $PAGE=1;
  $query1=mysql_query("select id, name, email , age from addd LIMIT ". (($PAGE * 5) - 5) .",5");
  
  echo "&lt;table&gt;&lt;tr&gt;&lt;td&gt;Testo&lt;/td&gt;&lt;td&gt;Nome&lt;/td&gt;&lt;td&gt;Anni&lt;/td&gt;&lt;/tr&gt;";
  
  function truncate_string($str, $length) {
  if (!(strlen($query2['name']) &lt;= $length)) {
      $query2['name'] = substr($query2['name'], 0, strpos($query2['name'], ' ', $length)) . '...';
  }
  
  return $query2['name'];
  }
  
  while($query2=mysql_fetch_array($query1))
  {
  $number= $query2['name'];
  echo "&lt;tr&gt;&lt;td&gt;".substr($query2['name'], 0, 500)."...&lt;/td&gt;";
  echo "&lt;td&gt;".$query2['email']."&lt;/td&gt;";
  echo "&lt;td&gt;".$query2['age']."&lt;/td&gt;";
  echo "&lt;td&gt;".str_word_count($number)."&lt;/td&gt;";
  echo "&lt;td&gt;&lt;a href='edit.php?id=".$query2['id']."'&gt;Mod&lt;/a&gt;&lt;/td&gt;";
  echo "&lt;td&gt;&lt;a href='delete.php?id=".$query2['id']."' onclick=\"return confirm('Sei sicuro di volerlo eliminare?');\");'&gt;Canc&lt;/a&gt;&lt;/td&gt;&lt;tr&gt;";
  echo "&lt;td&gt;&lt;a href='singletwo.php?id=".$query2['id']."');'&gt;vedi&lt;/a&gt;&lt;/td&lt;tr&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>The pages follow this numbering: ?page=1, ?page=2 ecc.</p>
  
  <p>Each page contains 5 news.</p>
  
  <p>How do I create an automatic pagination system? </p>
  
  <p>With Prev-Next, automatically detect possible next or previous pages?</p>
  
  <p>I don't know how to do it. </p>