rbragg Posted June 5, 2007 Share Posted June 5, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/ Share on other sites More sharing options...
unidox Posted June 5, 2007 Share Posted June 5, 2007 Code? Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268424 Share on other sites More sharing options...
taith Posted June 5, 2007 Share Posted June 5, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268430 Share on other sites More sharing options...
rbragg Posted June 5, 2007 Author Share Posted June 5, 2007 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; ?> Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268432 Share on other sites More sharing options...
rbragg Posted June 5, 2007 Author Share Posted June 5, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268524 Share on other sites More sharing options...
taith Posted June 5, 2007 Share Posted June 5, 2007 sorta... <?php while($all = mysql_fetch_array( $allResults )){ $countNew++; } if($_SESSION[count] < $countNew){ $_SESSION[count]= $countNew; echo 'encode sound'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268533 Share on other sites More sharing options...
rbragg Posted June 5, 2007 Author Share Posted June 5, 2007 I haven't tried this yet. I was just wondering how $_SESSION[count] would be initially set? I wanted to get the logic before I tried it out. Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268624 Share on other sites More sharing options...
taith Posted June 5, 2007 Share Posted June 5, 2007 it really doesnt need to be... 1 is greater then NULL but on your signin, you can set it to 0 if you really want... lol Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268638 Share on other sites More sharing options...
rbragg Posted June 5, 2007 Author Share Posted June 5, 2007 Would this need to be $_SESSION['count'] instead of $_SESSION[count] ? Quote Link to comment https://forums.phpfreaks.com/topic/54293-refresh-with-sound-if-new-record-found/#findComment-268661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.