Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Alert when new data is entered.

    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

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    I'm not entirely sure what you mean but I suspect maybe some sort of a cron job might help alert the moderator
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    84
    Thanks
    0
    Thanked 8 Times in 8 Posts
    I think I understand what you are saying. You could probably do something like
    Code:
    echo "<body";
    if(that thing happened){
      echo " onload=\"self.focus();\";
    }
    echo ">";

  • #4
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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

  • #5
    New Coder
    Join Date
    Oct 2007
    Posts
    84
    Thanks
    0
    Thanked 8 Times in 8 Posts
    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.
    Last edited by toddandrae; 11-23-2007 at 03:01 AM.

  • Users who have thanked toddandrae for this post:

    Hazer (11-23-2007)

  • #6
    New to the CF scene
    Join Date
    Nov 2007
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you toddandrae!

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

    Thanks everyone.
    Hazer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •