TYA , can someone help me , I want to show the id(PRIMARy/ AI) one at a time everytime I click the Next button. But in my code it just increment only and still show the previous number .
Here is the code:
<?php
    include 'dbh.php';
    $commentNewCount = $_POST['commentNewCount'];
    $sql = "SELECT * FROM comments LIMIT $commentNewCount";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            echo $row['id'];
        }
    } else {
        echo "There are number!";
    }
?>
Code in Js
$(document).ready(function() {
  var commentCount = 0;
  $("button").click(function() {
    commentCount = commentCount + 1;
    $("#comments").load("load-comments.php", {
      commentNewCount: commentCount
    });
  });
});
 
     
     
    