--- JaCoB <[EMAIL PROTECTED]> wrote:

> Is there a way to trigger a php script if a certain table on a database adds
> a new row (or Insert should i say)?
> 
> Example: If I have a shopping cart website then someone placed an order...
> there will be an alert on my local computer like a javascript alert.

>From a database perspective, it sounds like you are looking for a "trigger". 
These are not available on all database systems.  (You didn't say which DB you
are using).

You could run a cron job (if Unix/Linux/OS X) to run a script which would check
for new rows on a periodic basis (ie 1/minute if you are really anxious).  If
the condition is true, you could perform an action.  A good one would be to
send an email which would be retrieved on the next query for new messages.

What that action is will depend on your system.  If the page is open, it could
do the new row check and show results.  There are various ways to get a page to
reload or use something like AJAX to periodically send the request.  I'm not a
fan of this sort of thing since it gobbles up processing effort to constantly
loop and send queries.

Keep in mind that PHP is a server-side script.  It runs upon request.  Some of
the behaviors you are trying to implement are more like desktop applications
than web applications.

James

Reply via email to