Author Topic: RealTime Counter in MySql While Loop  (Read 2050 times)

dwhitaker

  • Posts: 2
    • View Profile
RealTime Counter in MySql While Loop
« on: November 29, 2004, 09:02:16 pm »
Posting Per Dean's Request

Dean,

I've been a member for a long time and I've sent you a lot of clients..

Anyway I'm building a program for a client, and as the mysql rows come
back he would like to see them count up in realtime.  
Just like text field counts when you send in ListMailPro...

Can you point me in the right direction on how to create something
that will count up as the rows are returned from mysql?

I can do this in a for loop, I assume I'll have to write some kind of
function to make this happen, in a While Loop...

Thanks...

Here's an example of the for loop in case anyone is wondering, what the heck I'm talking about.. <grin>

<html>
<head>
</head>

<body>
<input name="sent" type="text" id="sent" value="0">

<?
for($i = 0; $i <= 10000; $i++) {
echo "<script>this.sent.value='$i'</script>";
flush();
}
?>
</body>
</html>

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
RealTime Counter in MySql While Loop
« Reply #1 on: November 29, 2004, 09:39:13 pm »
You have the <script> and flush() part right.  It should increment your counter.  It won't work, however, if mod_gzip (a common Apache addon) is installed, or the PHP.INI setting "output_buffering = On" is set.   These settings cause the server to wait until the page is finished loading before compressing and sending any data to the browser.

Another thing to consider is you may need a <form></form> declaration to make the "this" object work.  If it still doesn't, try replacing "this" with the form name.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

dwhitaker

  • Posts: 2
    • View Profile
RealTime Counter in MySql While Loop
« Reply #2 on: November 29, 2004, 10:49:08 pm »
It does work in the above example for me...

output_buffering has "no value"
mod_gzip I'm not able to find in the httpd.conf, I'm assuming its not there...

The countup does work for me in ListMailPro....

I really think its because I'm not building a while statement the way it needs to be...  The whole while statement has to execute before the html will even load...

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
RealTime Counter in MySql While Loop
« Reply #3 on: November 30, 2004, 02:17:00 pm »
If the counter on ListMail works on the same server then your script should, too.  Did you try defining the form?
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting