title: How to Increment variable with button click , PHP\MySQL
body: <p>Button to click</p>
  
  <pre><code> &lt;form action='' method='POST'&gt;
                   &lt;input type='submit' name='submit' /&gt;
       &lt;/form&gt;
  </code></pre>
  
  <p>Variable to be incremented on button click </p>
  
  <pre><code>$currentid="1";
  if(isset($_POST['submit'])){
  
  $sql = "SELECT * from TABLENAME WHERE id='$currentid'  LIMIT 1";
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) {
      // output data of each row
      while($row = $result-&gt;fetch_assoc()) {
          echo "id: " . $row["id"]. " - Name: " . $row["name"].  "&lt;br&gt;";
          //$currentid=$row["id"];
          $currentid=$currentid+1;
          echo "$currentid";
      }
  } else {
      echo "0 results";
  }
  }
  </code></pre>
  
  <p>Task:</p>
  
  <p>I want to increment <code>$currentid="1"</code> by 1 each time the button is clicked.
  This will work same like php pagination but just with Next Button. and on each button click next record will be displayed.</p>
  
  <p>I would appreciate if you can suggest any other better way to achieve the same goal.</p>