...

View Full Version : Alert when new data is entered.



Hazer
11-22-2007, 02:21 PM
Hi

I have a php page which refreshs every 20 seconds. It pulls data from mysql database.

The problem is.. I need a way to alert the moderator when new data is updated, with the page minimized.

So a way to know when new data is submitted.

Also, the data from the page will be getting deleted, and more will be added etc.


Thanks,
Hazer

timgolding
11-22-2007, 10:21 PM
I'm not entirely sure what you mean but I suspect maybe some sort of a cron job might help alert the moderator

toddandrae
11-23-2007, 02:03 AM
I think I understand what you are saying. You could probably do something like


echo "<body";
if(that thing happened){
echo " onload=\"self.focus();\";
}
echo ">";

Hazer
11-23-2007, 02:43 AM
Store the result of mysql_num_rows() in a session and on page reload check mysql_num_rows() again to see if its greater than the previous session. If it is then echo out a javascript alert.

Well I think this is exactly what I am looking for. Now to do it.

Not entirely sure what toddandrae's code does. Can you please explain?

Thanks for the help.
Hazer

toddandrae
11-23-2007, 02:56 AM
It brings the window to focus if "that thing happened".

Edit: I would recommend storing the ID of the last row pulled in the session and comparing that to the current row pulled. This is just because you said that data will be deleted and added. There is a chance that the query could return the same number of rows. example: three rows were just deleted and three rows were added.

Hazer
11-23-2007, 03:09 AM
Thank you toddandrae!

I almost forgot about that I will be adding and deleting data. I will work on it.

Thanks everyone.
Hazer



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum