Jump to content

refresh with sound if new record found


rbragg

Recommended Posts

I have a call center page with a meta tag to refresh every 60 seconds. So, every 60 seconds the page checks for new records in my db.

 

I would like to have a sound play upon refresh only if a new record is found and displayed. I imagine that I would start at the top of the page with some sort of record count. My page uses sessions, so if there is a larger count than at the last check then the sound would play. Am I heading in the right direction?

 

Could someone help me get started? Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/
Share on other sites

sure...

 

do your loop info from the database, add a $count++;

 

if($_SESSION[count]<$count){
$_SESSION[count]=$count;
echo 'encode your sound here';
}

 

just as an fyi... if you count by sessions... when you first login... it'll beep wether it finds anything more there or not... lol

I haven't any yet other than my select statement and display:

<?php
$queryAll = "
SELECT *
FROM vigil_student, vigil_operator, vigil_call
WHERE vigil_student.studentID = vigil_call.studentID
AND vigil_operator.operatorID = vigil_call.operatorID
ORDER by time DESC
";  
$allResults = mysql_query($queryAll) or die( "All query failed: " . mysql_error() );			  

# count for alternate colors
$countRows = 0;

while($all = mysql_fetch_array( $allResults )) 
{ 
  # alternate colors for every row
  if ($countRows++ % 2 == 0){
  $style = "background-color: #F9F9F9;";
  } else {
  $style = "background-color: #FFFFFF;";
  }

$time = $all['time'];
echo "<tr class='style1' style='$style'><td>" . date("M j, y @ h:i a", strtotime($time) ) . "</td>";
echo "<td>" . $all['first'] . " " . $all['last'] . "</td>";
echo "<td>" . $all['hall'] . "</td>";
echo "<td>" . $all['room'] . "</td>";
echo "<td><img src='images/" . $all['status'] . ".gif'></td>";
echo "<td><a href='displayDetails.php?call=" . $all['callID'] . "'>details</a></td></tr>";
}

mysql_close;
?>

if($_SESSION[count]<$count){
$_SESSION[count]=$count;
echo 'encode your sound here';
}

 

I have a field (PK) in a table called callID that increments. This is what I would like to use for counting. So, with your logic would I do something like this?

 

<?php
while($all = mysql_fetch_array( $allResults )) 
{ 
  $countNew++;
  $countLast = $all['callID'];

  if $countLast < $countNew 
  {
    $countNew = $countLast;
    echo 'encode sound';
  }
}?>

 

Am I getting what you're saying?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.