对不起,但有人有实时警报的例子,例如
如果代理在午餐时间超过 10 分钟,则发出警报,并且取决于时间是插入到数据库中并插入到表中迟到
将非常有用谢谢
如果比较它以发出不同的警报,我真正想做什么,但我不知道该怎么做..这不起作用
警报.php:
<?php
$host = "" ;
$user = "" ;
$pw = "" ;
$db = "operator" ;
$fechaactual = Date("Y-m-d H:i:s");
$con = mysql_connect($host,$user,$pw) or die ("problemas al conectar");
$database=mysql_select_db($db,$con) or die ("problemas al conectar la bd");
$re = mysql_query(" SELECT * FROM operator ");
while($m=mysql_fetch_array($re)){
$ahi = (strtotime($m['tiempo']));
$ahi1 = date("Y-m-d", strtotime("+10 minutes", $ahi));
$ingresada = strtotime($ahi1);
$now = strtotime($fechaactual);
$lsk = mysql_query("SELECT * FROM lates WHERE id_op ='".$m['ID']."'");
if($ingresada > $now){
if(mysql_num_rows($lsk) == 0) {
echo "<script>";
echo "alert('".$m['nombre']." over pass the ".$m['status']."');";
echo "</script>";
mysql_query("INSERT INTO lates (id_op,nombre) VALUES ('".$m['ID']."','".$m['nombre']."')");
}else {
echo "is already inserted";}
}
}
?>
这是脚本:
<div id="alertas">
<?php include("alertas.php"); ?>
</div>
<script>
function conn() {
$("#alertas").load("alertas.php");
}
setInterval("conn()", 100);
</script>
我的表操作员...
CREATE TABLE `operator` (
`nombre` varchar(30) NOT NULL,
`status` enum('available','break1','break2','lunch','out') character set swe7 NOT NULL default 'available',
`tiempo` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`msj` varchar(30) default NULL,
`ID` int(15) unsigned NOT NULL auto_increment,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
我的桌子迟到了:
CREATE TABLE `lates` (
`id` int(50) NOT NULL auto_increment,
`id_op` int(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;