View Full Version : Php/Mysql live update

10-16-2009, 12:06 PM
Ok so i hope I have got this in the right catagory because it is kinda cross language coding...
What I need is a piece of text to be live on the page.
For instance, there are currently x users in our database.
I have this so far which displays the amount of users

We currently have
$username = "user";
$password = "pass";
$host = "localhost";
$database = "users";
$table = "users";
mysql_connect($host,$username,$password) or die("Error connecting to Database! " . mysql_error());
mysql_select_db($database) or die("Cannot select database! " . mysql_error());
$result = mysql_query("SELECT * FROM $table");
$num_rows = mysql_num_rows($result);
echo ($num1_rows + $num_rows); ?> users!
but how can i make it so if someone joins it will automatically update without refreshing the page?
Thanks in advance,
PS will i need to use javascript and/or AJAX?