title: Pagination won't work once its on page 2 PHP
body: <p>So basically everything shows when it's on search.php. However, once it gets to search.php?pn=2, The table and pagination navigation disappear. Here's the code</p>
  
  <pre><code>&lt;?php require('includes/header.php'); ?&gt;
  &lt;?php
  
  /* Array values
   * ------------
   * $_POST['search']; // the search field
   * $_POST['submitsearch']; // the search button
   * 
   */
  
  if(isset($_POST['submitsearch'])) {
      $search = mysql_real_escape_string(htmlentities(trim($_POST['search'])));
      $search = preg_split('/[\s]+/', $search);
      $total_words = count($search);
      $postsearch = $_POST['search'];
  
      if(empty($_POST['search'])) {
          echo "Enter something to search";
      }else{
          if(strlen($_POST['search']) &lt; 4) {
              echo "Search must be 3 or more characters long";
          }else{
             $where = "";
  
             foreach ($search as $key=&gt;$searches) {
                $where .= "description like '%{$searches}%'"; 
                if($key != $total_words - 1) {
                    $where.= " and ";
                }
             }
  
             $results = mysql_query("select name, left(description, 100) as description, logo, userid, number_sold, price from ns_products where $where") or die(mysql_error());
  
             echo "&lt;table border=1&gt;";
             if(mysql_num_rows($results)==0) {
                 echo "&lt;tr&gt;&lt;td&gt;No results found for &lt;strong&gt;$postsearch&lt;/strong&gt;.&lt;/td&gt;&lt;/tr&gt;";
             }else{
  
             //originial query
  $sql = mysql_query("select id, name, left(description, 100) as description, logo, userid, number_sold, price from ns_products where $where"); 
  //end of original query
  
  
  $nr = mysql_num_rows($sql); 
  if (isset($_GET['pn'])) { 
      $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); 
  } else {
      $pn = 1;
  } 
  
  $itemsPerPage = 3; 
  $lastPage = ceil($nr / $itemsPerPage);
  if ($pn &lt; 1) { 
      $pn = 1; 
  } else if ($pn &gt; $lastPage) { 
      $pn = $lastPage; // force it to be $lastpage's value
  } 
  // This creates the numbers to click in between the next and back buttons
  $centerPages = ""; // Initialize this variable
  $sub1 = $pn - 1;
  $sub2 = $pn - 2;
  $add1 = $pn + 1;
  $add2 = $pn + 2;
  if ($pn == 1) {
          $centerPages .= '&amp;nbsp; &lt;span class="pagNumActive"&gt;' . $pn . '&lt;/span&gt; &amp;nbsp;';
          $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $add1 . '"&gt;' . $add1 . '&lt;/a&gt; &amp;nbsp;';
  } else if ($pn == $lastPage) {
      $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $sub1 . '"&gt;' . $sub1 . '&lt;/a&gt; &amp;nbsp;';
  $centerPages .= '&amp;nbsp; &lt;span class="pagNumActive"&gt;' . $pn . '&lt;/span&gt; &amp;nbsp;';
  } else if ($pn &gt; 2 &amp;&amp; $pn &lt; ($lastPage - 1)) {
      $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $sub2 . '"&gt;' . $sub2 . '&lt;/a&gt; &amp;nbsp;';
  $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $sub1 . '"&gt;' . $sub1 . '&lt;/a&gt; &amp;nbsp;';
  $centerPages .= '&amp;nbsp; &lt;span class="pagNumActive"&gt;' . $pn . '&lt;/span&gt; &amp;nbsp;';
  $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $add1 . '"&gt;' . $add1 . '&lt;/a&gt; &amp;nbsp;';
  $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $add2 . '"&gt;' . $add2 . '&lt;/a&gt; &amp;nbsp;';
  } else if ($pn &gt; 1 &amp;&amp; $pn &lt; $lastPage) {
  $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $sub1 . '"&gt;' . $sub1 . '&lt;/a&gt; &amp;nbsp;';
  $centerPages .= '&amp;nbsp; &lt;span class="pagNumActive"&gt;' . $pn . '&lt;/span&gt; &amp;nbsp;';
  $centerPages .= '&amp;nbsp; &lt;a href="search.php?pn=' . $add1 . '"&gt;' . $add1 . '&lt;/a&gt; &amp;nbsp;';
  }
  
  $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage; 
  
  
  $sql2 = mysql_query("select id, name, left(description, 100) as description, logo, userid, number_sold, price from ns_products where $where $limit"); 
  
  
  $paginationDisplay = ""; 
  if ($lastPage != "1"){
      $paginationDisplay .= 'Page &lt;strong&gt;' . $pn . '&lt;/strong&gt; of ' . $lastPage. '&lt;img src="images/clearImage.gif" width="48" height="1"/&gt;';
      if ($pn != 1) {
          $previous = $pn - 1;
          $paginationDisplay .=  '&amp;nbsp;  &lt;a href="search.php?pn=' . $previous . '"&gt; Back&lt;/a&gt;     ';
      } 
      $paginationDisplay .= '&lt;span class="paginationNumbers"&gt;' . $centerPages . '&lt;/span&gt;';
      if ($pn != $lastPage) {
      $nextPage = $pn + 1;
      $paginationDisplay .=  '&amp;nbsp;  &lt;a href="search.php?pn=' . $nextPage . '"&gt; Next&lt;/a&gt;     ';
      } 
  }
  
  $num_results = mysql_num_rows($results);
  
  if($num_results == 1) {
      echo "Search has returned 1 result.";
  }else{
      echo "Search has returned $num_results results.";
  }
  
  echo "&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Description&lt;/td&gt;&lt;td&gt;Sold&lt;/td&gt;&lt;td&gt;Price&lt;/td&gt;&lt;td&gt;Owner&lt;/td&gt;&lt;/tr&gt;";
  //while loop here
  while($row8 = mysql_fetch_array($sql2)) {
      $prodname = $row8['name'];
      $prodid = $row8['id'];
      $proddesc = $row8['description'];
      $prodprice = $row8['price'];
      $prodlogo = $row8['logo'];
      $prodsold = $row8['number_sold'];
      $userid = $row8['userid'];
      $prodownerquery = mysql_fetch_assoc(mysql_query("select * from users where id='{$userid}'"));
      $prodowner = $prodownerquery['username'];
  
      echo "&lt;tr&gt;&lt;td&gt;&lt;img src=images/productpics/$prodlogo&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=viewproduct.php?pid=$prodid&gt;$prodname&lt;/a&gt;&lt;/td&gt;&lt;td width=200&gt;$proddesc...&lt;/td&gt;&lt;td&gt;$prodsold&lt;/td&gt;&lt;td&gt;$$prodprice&lt;/td&gt;&lt;td&gt;&lt;a href=viewuser.php?pid=$userid&gt;$prodowner&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;";
  
          }
         }
  
      }
     }
  }
  echo "&lt;/table&gt;";
  echo $centerPages;
  
  ?&gt;
  &lt;?php require('includes/footer.php') ?&gt;
  </code></pre>
  
  <p>Thanks!</p>