title: MySQL Query pagination with PHP
body: <p>How can i add a pagination system to this simple item display? And how i can add pagination for the results from filter? I just get lost that part and i cant figure it out!
  I want to apply CSS on the menu too!</p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;?php
                  include('db.php');
                  if(isset($_POST['filter']))
                  {
                      $filter = $_POST['filter'];
                      $result = mysql_query("SELECT * FROM products where Product like '%$filter%' or Description like '%$filter%' or Category like '%$filter%'");
                  }
                  else
                  {
                      $result = mysql_query("SELECT * FROM products");
                  }
                  while($row=mysql_fetch_assoc($result))
                  {
                      echo '&lt;li class="portfolio-item2" data-id="id-0" data-type="cat-item-4"&gt;';
                      echo '&lt;div&gt;
                      &lt;span class="image-block"&gt;
                      &lt;a class="example-image-link" href="reservation/img/products/'.$row['imgUrl'].'" data-lightbox="example-set" title="'.$row['Product'].'""&gt;&lt;img width="225" height="140" src="reservation/img/products/'.$row['imgUrl'].'" alt="'.$row['Product'].'" title="'.$row['Product'].'" /&gt;                    
                      &lt;/a&gt;
                      &lt;/span&gt;
                      &lt;div class="home-portfolio-text"&gt;
                      &lt;h2 class="post-title-portfolio"&gt;&lt;font color="#666666"&gt;'.$row['Product'].'&lt;/font&gt;&lt;/h2&gt;
                      &lt;p class="post-subtitle-portfolio"&gt;&lt;font color="#666666"&gt;Descrição: '.$row['Description'].'
                      &lt;p class="post-subtitle-portfolio"&gt;&lt;font color="#666666"&gt;Categoria: '.$row['Category'].'
                      &lt;p class="post-subtitle-portfolio"&gt;Código: '.$row['Price'].'&lt;/p&gt;&lt;br/&gt;&lt;/font&gt;&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;/div&gt;';
                      echo '&lt;/li&gt;';
                  }
                  ?&gt;
  </code></pre>
  
  <p>EDITED:</p>
  
  <pre><code>&lt;?php
                  include('db.php');
                  if(isset($_POST['filter']))
                  {
                      $filter = $_POST['filter'];
                      $result = mysql_query("SELECT * FROM products where Product like '%$filter%' or Description like '%$filter%' or Category like '%$filter%'");
                  }
                  else
                  {
  $start=0;
  $limit=6;
  
  if(isset($_GET['id']))
  {
      $id = $_GET['id'];
      $start = ($id-1)*$limit;
  }
  
  $result = mysql_query("SELECT * FROM products LIMIT $start, $limit");
                  }
  while($row = mysql_fetch_array($result))
  {
      echo '&lt;li class="portfolio-item2" data-id="id-0" data-type="cat-item-4"&gt;';
                      echo '&lt;div&gt;
                      &lt;span class="image-block"&gt;
                      &lt;a class="example-image-link" href="reservation/img/products/'.$row['imgUrl'].'" data-lightbox="example-set" title="'.$row['Product'].'""&gt;&lt;img width="225" height="140" src="reservation/img/products/'.$row['imgUrl'].'" alt="'.$row['Product'].'" title="'.$row['Product'].'" /&gt;                    
                      &lt;/a&gt;
                      &lt;/span&gt;
                      &lt;div class="home-portfolio-text"&gt;
                      &lt;h2 class="post-title-portfolio"&gt;&lt;font color="#666666"&gt;'.$row['Product'].'&lt;/font&gt;&lt;/h2&gt;
                      &lt;p class="post-subtitle-portfolio"&gt;&lt;font color="#666666"&gt;Descrição: '.$row['Description'].'
                      &lt;p class="post-subtitle-portfolio"&gt;&lt;font color="#666666"&gt;Categoria: '.$row['Category'].'
                      &lt;p class="post-subtitle-portfolio"&gt;Código: '.$row['Price'].'&lt;/p&gt;&lt;br/&gt;&lt;/font&gt;&lt;/p&gt;
                      &lt;/div&gt;
                      &lt;/div&gt;';
                      echo '&lt;/li&gt;';
  }
  echo "&lt;/ul&gt;";
  
  
  $rows = mysql_num_rows(mysql_query("SELECT * FROM products"));
  $total = ceil($rows/$limit);
  
  if($id&gt;1)
  {
      echo "&lt;center&gt;&lt;a href='?id=".($id-1)."' class='button'&gt;Anterior&lt;/a&gt;&lt;/center&gt;";
  }
  if($id!=$total)
  {
      echo "&lt;center&gt;&lt;a href='?id=".($id+1)."' class='button'&gt;Próximo&lt;/a&gt;&lt;/center&gt;";
  }
  
  ?&gt;
  </code></pre>