title: pagination $_GET['page'] in php
body: <p>I have a pagination question. When I load this page in the browser and click on the category link to show my products the first page shows with the products limited and the links for pagination are in place but it keeps sending me to the first page which is zero for whatever pagination link I click on. But the odd thing is is when I change</p>
  
  <pre><code>$offset=($pageNum - 1) * $perPage;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>$offset=($pageNum)= $perPage;
  </code></pre>
  
  <p>if shows the rest of the products I'm trying to show after clicking on the category. So the problem might be in the page or somewhere around there. </p>
  
  <p>Here is my code.</p>
  
  <pre><code>&lt;?php
  $productUlList="";
  error_reporting (E_ALL ^ E_NOTICE);
  include_once "convenientglobal2localhost.php";
  $result = mysql_query("SELECT * FROM category WHERE 1")or die(mysql_error());
  
  
  while($rowp=mysql_fetch_array($result)){
      $categoryId=$rowp['catId'];
      $categoryName=$rowp['catName'];
   $productUlList.='
      &lt;ul id="ul" &gt;
          &lt;li id="lists"&gt; &lt;a href="'.$_SERVER['PHP_SELF'].'?category='.$categoryName.'"&gt; '.$categoryName.'   &lt;/a&gt; &lt;/li&gt; 
      &lt;/ul&gt;';
  }
  ?&gt;
  &lt;?php
  $msg_to_user3='';
  
  $productList.='';
  $categoryList='';
  include_once "convenientglobal2localhost.php";
   $perPage= 3;
  if(isset($_GET['category']))
  
  
  $categoryNames=$_GET['category'];
  $pageNum=(isset($_GET['page']))? (int)$_GET['page']: 1;
  $pages_query= mysql_query("SELECT * FROM products INNER JOIN category ON categoryName=catName WHERE categoryName='$categoryNames'");
  $numrows= mysql_num_rows($pages_query);
   $maxpages=ceil($numrows / $perPage);
   $offset=($pageNum-1) * $perPage;
  if ($offset &lt; 0)
   {
   $offset = 0 ;
   }
  
  
  include_once "convenientglobal2localhost.php";
  $results = mysql_query("SELECT * FROM products WHERE categoryName='$categoryNames' LIMIT $offset, $perPage")or die(mysql_error());
  $num=mysql_num_rows($results);
  
  if($num &gt; 0){
  
  
  while($row=mysql_fetch_array($results)){
  
  
   $productId=$row['productId'];
   $productName=$row['name'];
   $productDescription=$row['description'];
   $productPrice=$row['price'];
   $productDiscountedPrice=$row['discountedPrice'];
   $productStock=$row['stock'];
   $productCategory=$row['categoryName'];
   $categoryId=$row['catId'];
   $catName=$row['catName'];
  
   $categoryList='&lt;table&gt;&lt;th id="toptable"&gt;&lt;/th&gt;&lt;/table&gt;
   &lt;table id="categorytable"&gt;
   &lt;th&gt;&lt;img src="inventory_category_images/' . $categoryId . '.jpg" width="498px"; height="125px";/&gt;&lt;/th&gt; 
  &lt;/table&gt;';
   $productList.='&lt;table id="productoutputtable"&gt;
   &lt;tr&gt;
   &lt;td rowspan="7" valign="top"&gt;&lt;img style="border-style=solid; border-color:#767475; padding=; "src="inventory_images/' . $productId . '.jpg" width="150" height="135"/&gt;
      &lt;/td&gt; 
      &lt;/tr&gt;
      &lt;tr&gt; 
      &lt;td id="tablecolor" &gt;&lt;strong&gt;Product&lt;/strong&gt;&lt;/td&gt; 
      &lt;td colspan="2"&gt;' . $productName . ' &lt;/td&gt; 
      &lt;td id="tablecolor"&gt;&lt;strong&gt;Category&lt;/strong&gt;&lt;/td&gt; 
      &lt;td&gt;' . $productCategory . ' &lt;/td&gt; 
      &lt;/tr&gt;
       &lt;tr&gt; 
      &lt;td id="tablecolor"&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;/td&gt; 
       &lt;td colspan="3"&gt;' . $productDescription . ' &lt;/td&gt; 
      &lt;/tr&gt; 
      &lt;tr&gt; 
      &lt;td id="tablecolor" &gt;&lt;strong&gt;Price:&lt;/strong&gt;&lt;/td&gt; 
       &lt;td&gt;$' . $productPrice . ' &lt;/td&gt;
       &lt;/tr&gt;&lt;tr&gt;
       &lt;td id="tablecolor"colspan="1"&gt;&lt;strong&gt;Sale Price:&lt;/strong&gt;&lt;/td&gt; 
      &lt;td&gt;$' . $productDiscountedPrice . ' &lt;/td&gt; 
      &lt;td id="tablecolor"colspan="2"&gt;&lt;strong&gt;In Stock &lt;/strong&gt;&lt;/td&gt; 
      &lt;td&gt;' . $productStock . ' &lt;/td&gt; 
      &lt;/tr&gt;
      &lt;/table&gt;';
  
  }   
  
  $self= $_SERVER['PHP_SELF'];
   for($page=1; $page&lt;=$maxpages; $page++){
      if($page == $pageNum){
          $nav= "$page";
      }
      else{
          $nav= "&lt;a href=\"$self?page=$page\"&gt;$page&lt;/a&gt;";
      }
   }
  
   if($page &gt; 1)
   {
      $page=$pageNum-1;
      $prev ="&lt;a href=\"$self?page=$page\"&gt;[Prev]&lt;/a&gt;";
      $first="&lt;a href=\"$self?page=1\"&gt;[First Page]&lt;/a&gt;";
   }
   else
   {
      $prev= "&amp;nbsp";
      $first="&amp;nbsp";
   }
   if($pageNum &lt; $maxPages)
   {
      $page=$pageNum+1;
      $next ="&lt;a href=\"$self?page=$page\"&gt;[Next]&lt;/a&gt;";
      $last="&lt;a href=\"$self?page=$maxPages\"&gt;[Last Page]&lt;/a&gt;";
   }
   else
   {
      $next= "&amp;nbsp";
      $last="&amp;nbsp";
   }
  $pageList.= $first. $prev. $nav. $next. $last;
  
   } 
  else{
      $msg_to_user3="You have no products listed.";
  
  }
  //$pageList.=""; 
  //for($i = 0 ; $i &lt;= $maxpages ; $i++) { 
  //if($i == $page) { 
  //$pageList.= "&lt;B&gt;$i&lt;/B&gt;"; 
  //}else{ 
  //$pageList.= '&lt;A HREF="?page='.$i.'"&gt;'.$i.'&lt;/A&gt;';
  //
  //} 
  //}
  ?&gt;
  </code></pre>
  
  <p>Thanks for all you help!!!</p>