Mysql
 sql >> Database >  >> RDS >> Mysql

Aggiornamento in tempo reale dei dati MySQL

Funziona, grazie per l'aiuto a tutti.

Javascript

$(document).ready(function(){    
    loadstation();
});

function loadstation(){
    $("#station_data").load("station.php");
    setTimeout(loadstation, 2000);
}

station.php

<?php
include ("database.php");

$result = mysqli_query($con, "SELECT * FROM sql347511.1 ORDER BY ID DESC LIMIT 1;");

while ($row = mysqli_fetch_array($result))
    {
    echo "<div class='infobox_data' id='infobox_temp'>" . $row['TEMP'] . "&deg;C</div>";
    echo "<div class='infobox_data' id='infobox_humid'>" . $row['HUMID'] . "%</div>";
    echo "<div class='infobox_time'>At " . date("g:i:s a F j, Y ", strtotime($row["TIME"])) . "</div>";
    }

mysqli_close($con);
?>

Dove mettere i dati

<div id="station_data"></div>