SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Know when a new report is displayed in admin

    I cant seem to think of a way of doing this, so that the manager viewing the admin area gets notified by an alert when a new report has been added.

    When the manager logs in there are already reports there, then when the page refreshes if a new report comes through how do you know that to create an alert.

    I understand that there might be a new ID in the database, but how do you grab the ID of the current newest report, and then compare it on refresh and then when a new report comes in when the page refreshes how do you compare the two to know that there a more current one there.

    These are the two scripts looking for the new reports@

    Code:
    <? $a=mysql_query("select count(UniqueIdentifier) as total1 from hazzard where HazardorNearMiss=''");
    $data=mysql_fetch_assoc($a);
    //echo $data['total1'];
    ?>
    
    
    <?
    $a=mysql_query("select UniqueIdentifier, Name, Employerofperson, Location, DateOccured, HazardorNearMiss from hazzard WHERE HazardorNearMiss='' ORDER by UniqueIdentifier DESC");
    while($x=mysql_fetch_assoc($a)){ 
    ?>

  2. #2
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,257
    Mentioned
    32 Post(s)
    Tagged
    5 Thread(s)
    If your records have a 'date created' timestamp or datetime field, you can do a simple calc in your script to mark all those created in the last 50 mins, and then display them in some way that they stand out from the rest.

  3. #3
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right I see yes, do a check on the records according to time.

    Thanks fretburner.

  4. #4
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im pretty sure this is correct below, but I dont seem to be able to view what I have selected in the database.

    Code:
    $fetch = mysql_query("SELECT DateOccured FROM hazzard LIMIT 1 ")or
    die(mysql_error()); ?>
    
    <?=$fetch['DateOccured']?>

  5. #5
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,257
    Mentioned
    32 Post(s)
    Tagged
    5 Thread(s)
    The mysql_query function only returns a resource - you have to pass that resource to another function such as mysql_fetch_assoc in order to get the data from it.


Bookmarks

Posting Permissions

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