title: PHP MYSQL Next AND Previous row
body: <p>Basically I have a table with data, and I have a form with boxes and stuff, and what I am trying to do is when the I click on the next or previous button, it will take the next record from the database. I can do the first and the last record, but I cant manage to figure the in between. this what I have.</p>
  
  <pre><code>$sql="SELECT * FROM Emails where ID &gt; 1 ORDER BY UserEmail LIMIT 1";
  
        if ($result=mysqli_query($connection,$sql))
        {
  
        // Return the number of rows in result set
        $rowcount=mysqli_num_rows($result);
  
        while( $row = mysqli_fetch_array( $result ) )
        {
           $Email_Field         = $row['UserEmail'];         //primary key
           $Name_Field          = $row['UserName'];           
           $UserTel             = $row['UserTel'];         
           $Drop_Down           = $row['Drop_down'];      
           $MessageType         = $row['MessageType'];       
           $Comments            = $row['Comments'];        
           $SubjectOther        = $row['SubjectOther'];        
           $Check               = $row['Request'];         
        }
  
   &lt;form method="POST" action="Controller_leads.php"&gt;
      &lt;p&gt;&lt;strong&gt;What kind of comment would you like to send?&lt;/strong&gt;&lt;/p&gt;
      &lt;input type="radio" &lt;?php if ($MessageType == "Complaint")   echo "checked"; ?&gt; name="MessageType" value="Complaint"&gt;Complaint 
      &lt;input type="radio" &lt;?php if ($MessageType == "Problem")   echo "checked"; ?&gt;  name="MessageType" value="Problem"&gt;Problem
      &lt;input type="radio" &lt;?php if ($MessageType == "Suggestion")   echo "checked"; ?&gt;  name="MessageType" value="Suggestion"&gt;Suggestion
      &lt;br&gt; 
      &lt;p&gt;&lt;strong&gt;What about us do you want to comment on?&lt;/strong&gt;&lt;/p&gt;
  
      &lt;select name="Drop_Down" size="1"&gt;
          &lt;option value ="Web Site" &lt;?php if ($Drop_Down == "Web Site") echo selected ?&gt;&gt;Web Site&lt;/option&gt;
          &lt;option value ="Office Hours" &lt;?php if ($Drop_Down == "Office hours") echo selected ?&gt;&gt;Office Hours&lt;/option&gt;
          &lt;option value ="Pamphlet" &lt;?php if ($Drop_Down == "Pamphlet") echo selected ?&gt;&gt;Pamphlet&lt;/option&gt;
      &lt;/select&gt;
  
      Other: &lt;input type="text" size="26" maxlength="256" name="SubjectOther" value="&lt;?php echo $SubjectOther ?&gt;"&gt;
  
      &lt;p&gt;&lt;strong&gt;Enter your comments in the space provided below:&lt;/strong&gt;&lt;/p&gt;
  
      &lt;textarea name="Comments" rows="5" cols="42"&gt;&lt;?php echo $Comments;?&gt;&lt;/textarea&gt;&lt;br&gt;&lt;br&gt;
  
      &lt;strong&gt;Tell us how to get in touch with you:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
  
      &lt;table&gt;
        &lt;tr&gt;&lt;td width="45"&gt;&amp;nbsp;Name     &lt;/td&gt; &lt;td&gt;&lt;input type="text" size="35" maxlength="256" name="UserName" value="&lt;?php echo $Name_Field ?&gt; "&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td width="45"&gt;&amp;nbsp;E-mail   &lt;/td&gt; &lt;td&gt;&lt;input type="text" size="35" maxlength="256" name="UserEmail" value="&lt;?php echo $Email_Field ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;td width="45"&gt;&amp;nbsp;Telephone&lt;/td&gt; &lt;td&gt;&lt;input type="text" size="35" maxlength="256" name="UserTel" value="&lt;?php echo $UserTel ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;/table&gt;
  
      &lt;br&gt;
      &lt;input type="checkbox" name="Check" &lt;?php if ($Check == "Contact Requested") echo checked; ?&gt; value="Contact Requested"&gt;Please contact me as soon as possible regarding this matter
      &lt;br&gt;&lt;br&gt; 
      &lt;input type="submit" value="First" name="first"&gt; 
      &lt;input type="submit" value="Next" name="next"&gt; 
      &lt;input type="submit" value="Previous" name="previous"&gt; 
      &lt;input type="submit" value="Last" name="last"&gt; code here
  </code></pre>