title: Loop at Biggest ID unless new bigger ID found
body: <p>I've got this running thanks to one of you.</p>
  
  <p>Concept is that this database will constantly be inserted with new entries and displaying them, <em>though</em> we need to have a plan be if there is a pause in user entries, loop it at current content.</p>
  
  <p><em>But</em>, now I have a difficulty to loop at the current row while there is no new ID.</p>
  
  <p>What this code is doing is constantly refreshing every 30sec and adding 1 to the row so it slowly displays content.</p>
  
  <p>Thing is, it will continue to retrieve even though there is no such ID.
  How do we get it to loop at current ID until next biggest ID is avail then display?</p>
  
  <p>And how do we include the <code>fadeOut</code> before previous ID content and <code>fadeIn</code> new ID content?</p>
  
  <pre><code>&lt;?php
          //connection via 
          require 'config.php';
  
          $conn = mysqli_connect( $db_host, $db_username, $db_password, $db_name);
  
          // Create connection
          if ($conn-&gt;connect_error) {
              die("Connection failed: " . $conn-&gt;connect_error);
          } 
  
          if (isset($_REQUEST["next_row"])) { 
              $myrow = 0;
              $myrow = $_REQUEST["next_row"];
          } if(isset($_REQUEST["next_row"]) &gt;=$myrow) {
              $myrow = $_REQUEST["next_row"]; }
          //else { $myrow = 0; }
  
          echo '&lt;form id=myform&gt; &lt;input type=text name="next_row" value="'.($myrow * 1+1).'"&gt; &lt;/form&gt;';
  
          //$toprow = "SELECT ID FROM demo WHERE ID DESC ";
          //if ($toprow == $myrow) {
          //    $myrow = $_REQUEST["next_row"]-1;
          //}
  
          //$sql = "SELECT * FROM `demo` ORDER BY `ID` DESC ";
          $sql = "SELECT * FROM demo ORDER BY ID DESC LIMIT 1 OFFSET ". $myrow;
          $result = $conn-&gt;query($sql);
  
          if ($result-&gt;num_rows &gt; 0) {
              // output data of each row
              while($row = $result-&gt;fetch_assoc()) {
                  echo '&lt;div id="main"&gt;';
                  echo '  &lt;p&gt;"'.$row["Comment"].'"&lt;br&gt;';
                  echo '  &lt;span&gt;'.$row["Name"].'&lt;/span&gt;&lt;br&gt;';
                  echo '  &lt;span&gt;'.$row["Org"].'&lt;/p&gt;';
                  echo "&lt;/div&gt;";
              }
  
          } //if ($result-&gt;num_rows &gt;= $sql) {
              //$myrow = $_REQUEST["next_row"]-1;
          //}
          else {
                  //$myrow = 0;
                  //echo "0 results";
                  echo '&lt;div id="main"&gt;';
                  echo '  &lt;p&gt;';
                  echo '      Welcome to Sydney Brenner Event!';
                  echo '  &lt;/p&gt;';
                  echo "&lt;/div&gt;";
              }
      $conn-&gt;close();        
      ?&gt;
          &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script&gt; 
              setTimeout(function(){ $('#myform').submit(); }, 29000); 
          &lt;/script&gt;
  </code></pre>