Continuously Update mysql query

I have a PHP scrpt that queries a database, and returns the number of records in the query.  The query works.  However, I need to have this number of records updated continuously.  So as other users add records, this counter increases WITHOUT reloading the page.  Any ideas?

I am thinking of something similar to ecommerce sites that as you put a new item in your cart, the counter showing the number of items in the cart increases, even though the page doesn't refresh.

Something similar to what Expert Exchange has for Open Questions and Question History.  The number of open questions is in () next to the Open Question Link.  I want something like that that updates dynamically without refreshing the whole web page.
$query_rs_select = "SELECT * FROM cbacks WHERE assessor_done = 0  AND mid_user = '$user' ";
$rs_select = mysql_query($query_rs_select, $connect_crm) or die(mysql_error());
$row_rs_select = mysql_fetch_assoc($rs_select);
$totalRows_rs_select = mysql_num_rows($rs_select);
 if(!mysql_num_rows($rs_select)) {
 
$upload = 0;
 
} else {
$upload = $totalRows_rs_select;
  
 
}
echo $upload;

Open in new window

fastfind1Asked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
>>WITHOUT reloading the page
I strongly suggest you look at the following ajax tutorial:
http://w3schools.com/ajax/ajax_intro.asp

so that you can understand the db example:
http://w3schools.com/ajax/ajax_database.asp

for your purposes, you will need to send periodic ajax requests
0
 
wassa_rConnect With a Mentor Commented:
Use AJAX together with a javascript library like jQuery. You then build a PHP page that simply outputs the number of rows, and do a periodical updater that updates the page every few seconds. It'll look like the page never reloads, and it updates the counter.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.