I've got this running thanks to one of you.
Concept is that this database will constantly be inserted with new entries and displaying them, though we need to have a plan be if there is a pause in user entries, loop it at current content.
But, now I have a difficulty to loop at the current row while there is no new ID.
What this code is doing is constantly refreshing every 30sec and adding 1 to the row so it slowly displays content.
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?
And how do we include the fadeOut
before previous ID content and fadeIn
new ID content?
<?php
//connection via
require 'config.php';
$conn = mysqli_connect( $db_host, $db_username, $db_password, $db_name);
// Create connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_REQUEST["next_row"])) {
$myrow = 0;
$myrow = $_REQUEST["next_row"];
} if(isset($_REQUEST["next_row"]) >=$myrow) {
$myrow = $_REQUEST["next_row"]; }
//else { $myrow = 0; }
echo '<form id=myform> <input type=text name="next_row" value="'.($myrow * 1+1).'"> </form>';
//$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->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<div id="main">';
echo ' <p>"'.$row["Comment"].'"<br>';
echo ' <span>'.$row["Name"].'</span><br>';
echo ' <span>'.$row["Org"].'</p>';
echo "</div>";
}
} //if ($result->num_rows >= $sql) {
//$myrow = $_REQUEST["next_row"]-1;
//}
else {
//$myrow = 0;
//echo "0 results";
echo '<div id="main">';
echo ' <p>';
echo ' Welcome to Sydney Brenner Event!';
echo ' </p>';
echo "</div>";
}
$conn->close();
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>
setTimeout(function(){ $('#myform').submit(); }, 29000);
</script>