View Full Version : Alert when new data is entered.

11-22-2007, 03:21 PM

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.


11-22-2007, 11: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

11-23-2007, 03: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 ">";

11-23-2007, 03: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.

11-23-2007, 03: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.

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

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

Thanks everyone.