I need help with the script. I want to show the result on page only when payload=1,if payload=0 do not display..
I've tried messing with mysql statements and I realized I need to change that in my script
this is my php:
    <?php
    $dbhost = "localhost";
    $dbuser = "user";
    $dbpass = "pass";
    $dbname = "rooms";
    $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
    if(! $conn ) {
    die('Could not connect: ' . mysqli_error());
    }
    echo 'Connected successfully<br>';
    $sql = "SELECT ID, topic, payload, DateTime_created FROM room1  ORDER 
    BY id DESC LIMIT 1 ";
    $retval = mysqli_query( $conn, $sql );
    if(! $retval ) {
    die('Could not get data: ' . mysqli_error());
    }
    while($row = mysqli_fetch_assoc($retval)) {
    echo "ID: " . $row["id"]. "<br>";
    echo "Topic: " . $row["topic"]. "<br>";
    echo "Payload: " . $row["payload"]. "<br>";
    echo "Timestamp: " . $row["DateTime_created"]. "<br>";
    }
   mysqli_free_result($retval);
   echo "Fetched data successfully\n";
   mysqli_close($conn);
my database is: rooms table:room1 ID topic payload DateTime_created
and my index.html
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script 
  src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> 
  type="text/javascript" charset="utf-8"></script>
  <script>
  $(document).ready(function(){
  sendRequest();
  function sendRequest(){
      $.ajax({
        url: "vineri.php",
        success: 
          function(data){
           $('#listposts').html(data); 
        },
        complete: function() {
       // Schedule the next request when the current one's complete
       setInterval(sendRequest, 5000); // The interval set to 5 seconds
     }
     });
   };
    });
    </script>
    </head>
    <body>
    <div id="listposts"> </div>
    </body>
How do I get the result to display only when the payload is 1 ?