织梦后台表单数据提醒
只是个简单查询:
1 在dede/index.php 中写入一行代码:require(DEDEADMIN.'/../plus/form_alert.php');
2 然后在 dede/templets/index2.htm 的 "<div class="sysmsg"><h3>滚动消息:</h3>" 部位改变代码:
<h3><?php if(isset($formAddMsg)){echo $formAddMsg . '有消息';} ?></h3>
<script type="text/javascript">
$(function(){
function getFormMsg() {
$.ajax({
type: 'get',
url: '/plus/form_alert_ajax.php',
data: 'getform=1',
dataType: 'json',
success: function(re) {
var res = re;
console.log(res);
if(res != 'false'){
$('.sysmsg>h3').text(res+'有消息');
} else {
$('.sysmsg>h3').text('无消息');
}
}
});
}
var timer = setInterval(getFormMsg,120000);
});
</script>
3 增加文件 ./plus/form_alert_ajax.php 代码:
1 <?php 2 require_once ("/../include/common.inc.php"); 3 4 if($dsql->IsTable('qx_diyform1')){ 5 //如果存在qx_diyform1表 6 //------------------- 7 $sql = "SELECT count(ifcheck) FROM qx_diyform1 WHERE ifcheck = 0"; 8 $dsql->Execute('me',$sql); 9 if($dsql->GetArray('me')['count(ifcheck)']>0){ 10 $formAddMsg = ' qx_diyform1 '; 11 } 12 } 13 if($dsql->IsTable('qx_diyform2')){ 14 //如果存在qx_diyform2表 15 //------------------- 16 $sql = "SELECT count(ifcheck) FROM qx_diyform2 WHERE ifcheck = 0"; 17 $dsql->Execute('me',$sql); 18 if($dsql->GetArray('me')['count(ifcheck)']>0){ 19 $formAddMsg .= ' qx_diyform2 '; 20 } 21 } 22 if($dsql->IsTable('qx_diyform3')){ 23 //如果存在qx_diyform3表 24 //------------------- 25 $sql = "SELECT count(ifcheck) FROM qx_diyform3 WHERE ifcheck = 0"; 26 $dsql->Execute('me',$sql); 27 if($dsql->GetArray('me')['count(ifcheck)']>0){ 28 $formAddMsg .= ' qx_diyform3 '; 29 } 30 } 31 $res = isset($formAddMsg) ? $formAddMsg : 'false'; 32 echo json_encode($res);
结果如下: