作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我正在使用通知,如果我添加新记录,菜单中会出现通知。
这里通知工作正常,但问题是如果我刷新页面然后只有菜单通知可见,如果我添加新记录我如何立即显示通知
现在我的想法是在不干扰页面内容的情况下刷新整个页面,行得通吗?
<?php
ini_set("display_errors",0);
$query="SELECT count(*) as count FROM patients AS p,users AS u WHERE p.status='a' AND p.confirm_status='p' AND p.users_id_user=u.id_user";
$resultPatients=$db->select($query);
$pendingAppointments=0;
if($resultPatients && count($resultPatients)>0)
{
$pendingAppointments=$resultPatients[0]['count'];
}
$query="SELECT count(*) as count FROM query WHERE shown_status='n'";
$resultQueries=$db->select($query);
$pendingQueries=0;
if($resultQueries && count($resultQueries)>0)
{
$pendingQueries=$resultQueries[0]['count'];
}
$query="SELECT count(*) as count FROM feedback WHERE shown_status='n'";
$resultFeedbacks=$db->select($query);
$pendingFeedbacks=0;
if($resultFeedbacks && count($resultFeedbacks)>0)
{
$pendingFeedbacks=$resultFeedbacks[0]['count'];
}
$query="SELECT count(*) as count FROM register WHERE shown_status='n'";
$resultRegisters=$db->select($query);
$pendingRegisters=0;
if($resultRegisters && count($resultRegisters)>0)
{
$pendingRegisters=$resultRegisters[0]['count'];
}
$query="SELECT count(*) as count FROM unregister WHERE shown_status='n'";
$resultunRegisters=$db->select($query);
$pendingunRegisters=0;
if($resultunRegisters && count($resultunRegisters)>0)
{
$pendingunRegisters=$resultunRegisters[0]['count'];
}
?>
<div class="mainNav">
<div class="user">
<a title="" href="index.php" class="leftUserDrop"><img src="images/icare.png" height="100" width="100" alt="" /><!--span><strong>3</strong></span--></a>
<!--ul class="leftUser">
<li><a href="#" title="" class="sProfile">My profile</a></li>
<li><a href="#" title="" class="sMessages">Messages</a></li>
<li><a href="#" title="" class="sSettings">Settings</a></li>
<li><a href="#" title="" class="sLogout">Logout</a></li>
</ul-->
</div>
<!-- Responsive nav -->
<div class="altNav">
<div class="userSearch">
<form action="">
<input type="text" placeholder="search..." name="userSearch" />
<input type="submit" value="" />
</form>
</div>
<!-- User nav -->
<ul class="userNav">
<li><a href="#" title="" class="profile"></a></li>
<li><a href="#" title="" class="messages"></a></li>
<li><a href="#" title="" class="settings"></a></li>
<li><a href="#" title="" class="logout"></a></li>
</ul>
</div>
<!-- Main nav -->
<ul class="nav">
<li><a href="index.php" title="" <?php if($_SESSION['menu']=='index') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/dashboard.png" height="30" width="30" alt="" /><span>Dashboard</span></a></li>
<?php
$totalcount=$pendingQueries+$pendingRegisters;
?>
<li><a href="users.php" title="" <?php if($_SESSION['menu']=='user') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/ui.png" height="30" width="30" alt="" /><span>Users</span><span class="requestSpan" ><?php if($totalcount>0) {?><strong id="queryCount"><?php echo $totalcount?></strong><?php }?></span></a></li>
<li><a href="doctors.php" title="" <?php if($_SESSION['menu']=='doctor') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/doctors.png" height="30" width="30" alt="" /><span>Doctors</span></span></a></li>
<?php
$totalcount2=$pendingAppointments+$pendingunRegisters;
?>
<li><a href="appointments.php" title="" <?php if($_SESSION['menu']=='patient') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/appointments.png" height="30" width="30" alt="" /><span>Appointments</span><span class="requestSpan" id="queryCount1"><?php if($totalcount2>0) {?><strong id="queryCount1"><?php echo $totalcount2?></strong><?php }?></span></a></li>
<li><a href="feedbacks.php" title="" <?php if($_SESSION['menu']=='feedback') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/forms.png" height="30" width="30" alt="" /><span>Feedbacks</span><span class="requestSpan" id="mainFeedbackCount"><?php if($pendingFeedbacks>0) {?><strong id="feedbackCount"><?php echo $pendingFeedbacks?></strong><?php }?></span></a></li>
<li><a href="offers.php" title="" <?php if($_SESSION['menu']=='offer') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/offers.png" height="30" width="30" alt="" /><span>Offers</span></a></li>
<!--li><a href="slots.php" title="" <?php if($_SESSION['menu']=='slot') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/about.png" height="30" width="30" alt="" /><span>Info</span></a></li-->
<li><a href="photos.php" title="" <?php if($_SESSION['menu']=='photo') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/upload.png" height="30" width="30" alt="" /><span>Photos</span></a></li>
<li><a href="services.php" title="" <?php if($_SESSION['menu']=='services') { ?> class="active" <?php } ?> ><img src="images/icons/mainnav/services.png" height="30" width="30" alt="" /><span>Services</span></a></li>
</ul>
</ul>
</div>
<div id="sound" style="display: none"></div>
<script type="text/javascript">
function playSound(filename){
document.getElementById("sound").innerHTML='<audio autoplay="autoplay"><source src="' + filename + '.mp3" type="audio/mpeg" /><source src="' + filename + '.ogg" type="audio/ogg" /><embed hidden="true" autostart="true" loop="false" src="' + filename +'.mp3" /></audio>';
}
function getNotification()
{
var request=$.ajax({
url: "getNotificationCounts.php",
dataType: "json",
async: false
});
request.done(function(response){
var queryCount=$('#queryCount').html();
var queryCount1=$('#queryCount1').html();
var appointmentCount=$('#appointmentCount').html();
var feedbackCount=$('#feedbackCount').html();
var status=false;
if(response.queries>0)
{
if(!queryCount)
{
status=true;
$('#mainQueryCount').html('<strong id="queryCount"></strong>');
}
if(queryCount!=''&&response.queries>parseInt(queryCount))
status=true;
$('#queryCount').html(response.queries);
}
if(response.unregister>0)
{
if(!queryCount1)
{
status=true;
$('#mainQueryCount1').html('<strong id="queryCount1"></strong>');
}
if(queryCount1!=''&&response.queries1>parseInt(queryCount1))
status=true;
$('#queryCount1').html(response.unregister);
}
if(response.appointments>0)
{
if(!appointmentCount)
{
status=true;
$('#mainAppointmentCount').html('<strong id="appointmentCount"></strong>');
}
if(appointmentCount!=''&&response.appointments>parseInt(appointmentCount))
status=true;
$('#appointmentCount').html(response.appointments);
}
if(response.feedbacks>0)
{
if(!feedbackCount)
{
status=true;
$('#mainFeedbackCount').html('<strong id="feedbackCount"></strong>');
}
if(feedbackCount!=''&&response.feedbacks>parseInt(feedbackCount))
status=true;
$('#feedbackCount').html(response.feedbacks);
}
if(status)
playSound('bing');
});
}
setInterval(function(){getNotification();},30000);
</script>
我是一名优秀的程序员,十分优秀!