calling php file

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

calling php file

Post by shivam0101 »

Is there any way of calling a php file using mysql trigger?

Thanks
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: calling php file

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Why would you need to? Please explain your situation and perhaps better logic could be thought of.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

actually i want to show currently logged in members.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

That's easily done with a php file with a call to mysql_query().
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

something similar to gmail, at realtime.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

mysql_query() in a php file and AJAX
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post 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.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

XMLHttp tutorial (who's online example) could be a useful thing to look at.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post 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?
josa
Forum Commoner
Posts: 75
Joined: Mon Jun 24, 2002 4:58 am
Location: Sweden

Post 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
Last edited by josa on Wed Sep 05, 2007 7:27 am, edited 1 time in total.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Post Reply