Looking for a solution to have php refresh when new data hits database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #16
    Heya, Frank.

    Try a hybrid.
    • When the User updates the database, log the timestamp.
    • While a User is logged in, check via AJAX once every X seconds to see if this timestamp has changed and alert the User if it has. Update a different timestamp every time the AJAX call connects so that you know that the User has been notified.
    • Once per X hours, send a notification email to every user where their check-for-updates timestamp is less that their database-was-modified timestamp.
    • You can create a separate table that lists the modification timestamps for each table if you want to be able to determine which tables were modified when sending emails / AJAX results.

    Comment

    • fjm
      Contributor
      • May 2007
      • 348

      #17
      Originally posted by pbmods
      Heya, Frank.

      Try a hybrid.
      • When the User updates the database, log the timestamp.
      • While a User is logged in, check via AJAX once every X seconds to see if this timestamp has changed and alert the User if it has. Update a different timestamp every time the AJAX call connects so that you know that the User has been notified.
      • Once per X hours, send a notification email to every user where their check-for-updates timestamp is less that their database-was-modified timestamp.
      • You can create a separate table that lists the modification timestamps for each table if you want to be able to determine which tables were modified when sending emails / AJAX results.
      Hey Pbmods..

      Timestamps.. Of course. I can have AJAX look for a change then alert. Not quite sure how to do that yet with AJAX. Is there a complete AJAX script that you know of that I can use or is this something that I would have to write? I do not know AJAX at all.

      Thanks,

      Frank

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #18
        Heya, Frank.

        On the PHP side, simply echo strtotime({date from db}); Then on the javascript side, you can compare the last timestamp with the new one; they'll both be unsigned integers (hopefully).

        Comment

        • jx2
          New Member
          • Feb 2007
          • 228

          #19
          Originally posted by fjm
          Hey Pbmods..

          Timestamps.. Of course. I can have AJAX look for a change then alert. Not quite sure how to do that yet with AJAX. Is there a complete AJAX script that you know of that I can use or is this something that I would have to write? I do not know AJAX at all.

          Thanks,

          Frank
          hey
          you should look here

          in your case that very easy you send "ajax" request to serwer - if there is new record php send this record(or just worning) back to browser if there is no new records then it send empty string

          i woud have <span id='newrecord'> on my page</span> and whatever you going to send back it can be displayed there with javascript

          regars jx2

          Comment

          Working...