Page 1 of 1

calling php file

Posted: Mon Sep 03, 2007 9:11 pm
by shivam0101
Is there any way of calling a php file using mysql trigger?

Thanks

Re: calling php file

Posted: Mon Sep 03, 2007 9:35 pm
by califdon
shivam0101 wrote:Is there any way of calling a php file using mysql trigger?

Thanks
As far as I know, no. I believe database triggers can only operate on the database.

Posted: Mon Sep 03, 2007 9:37 pm
by s.dot
Why would you need to? Please explain your situation and perhaps better logic could be thought of.

Posted: Mon Sep 03, 2007 9:42 pm
by shivam0101
actually i want to show currently logged in members.

Posted: Mon Sep 03, 2007 10:02 pm
by s.dot
That's easily done with a php file with a call to mysql_query().

Posted: Mon Sep 03, 2007 10:12 pm
by shivam0101
something similar to gmail, at realtime.

Posted: Mon Sep 03, 2007 10:32 pm
by s.dot
mysql_query() in a php file and AJAX

Posted: Tue Sep 04, 2007 2:12 am
by shivam0101
I went through this tutorial,

http://www.zeitoun.net/index.php?2007/0 ... t-with-php

example of current time. Modified the code to

Code: Select all

while(1) {

   $query_check=mysql_query("SELECT * FROM online ORDER BY member_id DESC");
   $num_check=mysql_num_rows($query_check);
   $table_current="<table border=1><tr>";
   while($fetch=mysql_fetch_array($query_check))
	{
	  $online=$cls_obj->GetMemberPhoto($memberId, $fetch['member_id']);
	  $table_current.="<td>$online</td>";
	}
    $table_current.="</tr></table>";
	  
	  echo '<script type="text/javascript">';
	  echo "comet.printServerTime('$table_current')";
	  echo '</script>';
	  flush(); 
  
  usleep(10000);
}
feyd, should i have to move this posting to code category?

The problem is, it slows down and also i cant even click other links to navigate to other pages. Is there any better way of implementing this code? Please let me know.

Posted: Tue Sep 04, 2007 4:34 am
by CoderGoblin
XMLHttp tutorial (who's online example) could be a useful thing to look at.

Posted: Tue Sep 04, 2007 8:54 pm
by shivam0101
Thanks CoderGoblin.

But, it is not in realtime. We have to wait for 30 sec.

Which language google uses? Is there any feature in that language which is not available in PHP?

Posted: Wed Sep 05, 2007 7:23 am
by josa
Strictly speaking you can't get realtime, but in practice you can have the javascript code update the page as often as you like (certainly more often than every 30 seconds). XMLHttp is what you need for this and I think you should read the tutorial that CoderGoblin suggested.

/josa

Posted: Wed Sep 05, 2007 7:26 am
by superdezign
shivam0101 wrote:But, it is not in realtime. We have to wait for 30 sec.
Every time you refresh, you use up bandwidth. If you want to do it every second, you are welcome to do so. You must put into account that not all users are broadband users, however, and each page request usually takes more than a second.
shivam0101 wrote:Which language google uses? Is there any feature in that language which is not available in PHP?
Google uses a lot of languages. But, for what your referring to, they use AJAX.

Posted: Wed Sep 05, 2007 7:37 am
by CoderGoblin
XMLHttp tutorial (who's online example) wrote:...XMLHttp is the precursor to ajax and ajax actually uses XMLHttp to work. Understanding XMLHttp will significantly help you understand and consequently develop applications that are Ajax driven. For more information on Ajax alone, try googling it and you'll come up with a plethora of information...
The advantage of using XMLHttp/Ajax is that you only update "part" of a page rather than the whole page. You are obviously restricted to those people who use javascript. Another thing to bear in mind when thinking how often you want the users online to be updated is how long it takes to get the information and what happens to a user when the javascript kicks in to get the information. Users generally hate it when a waiting cursor comes up or link doesn't work immediately when they click it. This can happen if the page is constantly updating information by running javascript.