Can someone explain how to create a .php page which auto-updates with values from a database? Would using AJAX be best for something like this? I want this PHP code, but I want the page to be updated whenever 'values01' is added to or changed, without having to refresh the page.
$query = "SELECT values01 FROM users WHERE username='$username'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo nl2br("{$row['values01']}");
}
Any help would be appreciated! :)
What you are describing would be a push notification from the web server. Unfortunately, I have not found a reliable way to do a traditional push, where the web server would initiate the connection with the client (from my limited research, it appears that there were proposals for the http standard to support push, however, it doesn't look like a widely adopted standard ever emerged). However, this can be done in a bit more roundabout way.
There is a way around the push limitation that is typically used:
The only thing you are missing here from a typical push notification, is the 10-second (or whatever you choose for your timer) lag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With