title: Passing Multiple Variables Through Pages PHP MYSQL
body: <p>The following code is working fine for the first page. It is a query based on user input from a form. I have 2 issues. The first one is when i click next page i get undefined index and undefined variable error which means the variables are not passed. The second question is how can i make a query and paginate it based on the user filled/selected values in the form? Some users may not fill all the values.
  Here is my code: NB: The form method is GET. I have tried REQUEST and POST too. All the same error. Thanks in advance guys.</p>
  
  <pre><code>&lt;?php   
  
      if (isset($_POST['Submit'])) 
      $name = mysql_real_escape_string($_GET['name']);
      $email = mysql_real_escape_string($_GET['email']);
      $age = mysql_real_escape_string($_GET['age']);
      $height = mysql_real_escape_string($_GET['height']);
  
      include_once "conn.php"; //connect to db and table
  
      $rs = mysql_query("SELECT COUNT(*) FROM people WHERE name='$name' AND email='$email' AND age='$age' AND height='$height'"); 
      $rw = mysql_fetch_array($rs);
      $numrows = $rw[0];
  if ($numrows== 0) die("No Results Found");
  
  $rowsperpage = 7;
  
  $totalpages = ceil($numrows / $rowsperpage);
  
  
  if (isset($_GET['currentpage']) &amp;&amp; is_numeric($_GET['currentpage'])) {
  
     $currentpage = (int) $_GET['currentpage'];
  } else {
  
     $currentpage = 1;
  } 
  if ($currentpage &gt; $totalpages) {
  
     $currentpage = $totalpages;
  } 
  if ($currentpage &lt; 1) {
  
     $currentpage = 1;
  } 
  $offset = ($currentpage - 1) * $rowsperpage;
  
      $query = mysql_query("SELECT * FROM people WHERE name='$name' AND email='$email' AND age='$age' AND height='$height' ORDER BY time DESC LIMIT $offset, $rowsperpage"); 
  
  //print my tables here 
  
  while($row = mysql_fetch_array($query)) 
                 {       
                     $uniqueid = $row['age'];
  //output stuff here   
                 }
  //close sql
  $range = 3;
  if ($currentpage &gt; 1) {
     echo " &lt;a href='{$_SERVER['PHP_SELF']}?currentpage=1&amp;amp;name=$name&amp;amp;email=$email&amp;amp;age=$age&amp;amp;height=$height'&gt; Go To Page 1&lt;/a&gt; ";
  
     $prevpage = $currentpage - 1;
  
     echo "&lt;a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&amp;amp;name=$name&amp;amp;email=$email&amp;amp;age=$age&amp;amp;height=$height'&gt; Previous Page&lt;/a&gt;";
  } 
  for ($x = ($currentpage - $range); $x &lt; (($currentpage + $range) + 1); $x++) {
  
     if (($x &gt; 0) &amp;&amp; ($x &lt;= $totalpages)) {
  
        if ($x == $currentpage) {
  
           echo " &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font size=4 color=red&gt;[&lt;b&gt;$x&lt;/b&gt;] &lt;/font&gt;";
  
        } else {
  
           echo "&lt;a href='{$_SERVER['PHP_SELF']}?currentpage=$x&amp;amp;name=$name&amp;amp;email=$email&amp;amp;age=$age&amp;amp;height=$height'&gt;$x&lt;/a&gt;";
        } 
     }  
  }        
  if ($currentpage != $totalpages) {
  
     $nextpage = $currentpage + 1;
  
     echo "&lt;a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&amp;amp;name=$name&amp;amp;email=$email&amp;amp;age=$age&amp;amp;height=$height'&gt;Next Page&lt;/font&gt;&lt;/a&gt;";
  
     echo "&lt;a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&amp;amp;name=$name&amp;amp;email=$email&amp;amp;age=$age&amp;amp;height=$height'&gt;Last Page&lt;/a&gt; ";
  } 
  
  ?&gt;
  </code></pre>