"说思路的就不要来了",这句话,十个人走了九个半。这是一个播放音乐的。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta http-equiv="refresh" content="2">
</head><input type="text" id="t" />
<?php
$rcnt = .... ; // 这里是你自己的语句,查询是不是有符合的记录
if ($rcnt >= 0) {
?>
<embed src=ring.mp3 width=0 height=0 type=audio/mpeg loop="true" autostart="true">
<?php
}
?><body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta http-equiv="refresh" content="2">
</head><input type="text" id="t" />
<?php
$rcnt = .... ; // 这里是你自己的语句,查询是不是有符合的记录
if ($rcnt >= 0) {
?>
<embed src=ring.mp3 width=0 height=0 type=audio/mpeg loop="true" autostart="true">
<?php
}
?><body>
</body>
</html>
很赞同,楼主既然是请教,就虚心点吧。
mysql原始查询语句拿去吧。mysql_connect(主机,用户名,密码);
mysql_set_charset('utf8');
mysql_select_db('weicms');
$sql='select * from weicms.weicms_hotel_order where order_status=1';
$result=mysql_query($sql);
$list=array();
if($result && mysql_num_rows($result)>0){
while($row=mysql_fetch_assoc($result)){
$list[]=$row;
}
mysql_free_result($result);
}
return $result;
<script type="text/javascript">
var url = "处理页面";
var Comet = Class.create();
Comet.prototype = { timestamp: 0,
url: url,
noerror: true, initialize: function() { }, connect: function()
{
this.ajax = new Ajax.Request(this.url, {
method: 'get',
parameters: { 'timestamp' : this.timestamp },
onSuccess: function(transport) {
// handle the server response
var response = transport.responseText.evalJSON();
this.comet.timestamp = response['timestamp'];
this.comet.handleResponse(response);
this.comet.noerror = true;
},
onComplete: function(transport) {
// send a new ajax request when this request is finished
if (!this.comet.noerror)
// 每60秒请求一次
setTimeout(function(){ comet.connect() }, 60000);
else
this.comet.connect();
this.comet.noerror = false;
}
});
this.ajax.comet = this;
}, handleResponse: function(response)
{
if(response['timestamp'] >xx){
alert('新订单');
}
} }
var comet = new Comet();
comet.connect();
</script>$filename = dirname(__FILE__).'/data.txt';
// store new message in the file
$msg = isset($_GET['msg']) ? $_GET['msg'] : '';
if ($msg != '')
{
file_put_contents($filename,$msg);
die();
}
// infinite loop until the data file is not modified
$lastmodif = isset($_GET['timestamp']) ? $_GET['timestamp'] : 0;
$currentmodif = filemtime($filename);
while ($currentmodif <= $lastmodif) // check if the data file has been modified
{
usleep(10000); // sleep 10ms to unload the CPU
clearstatcache();
$currentmodif = filemtime($filename);
}
// return a json array
$response = array();
$response['msg'] = file_get_contents($filename);
$response['timestamp'] = $currentmodif;
echo json_encode($response);
逻辑就是 前台下单的时候 往一个txt文档中写入数据 文档最后修改时间就会更改。 然后后台轮询查询文件时间, 如果不同 证明有新数据 则提醒 楼主自己改成想要的 大致就这么个流程 再不会我也没办法了