🎉 طعم یادگیری با دورهمی‌های هفتگی در یک نقشه راه کامل آموزش برنامه نویسی (آفر ویژه ثبت نام قبل از افزایش قیمت🔥)
۰ ثانیه
۰ دقیقه
۰ ساعت
۱ ابراهیم محمدی
Notification
جامعه پی اچ پی ایجاد شده در ۰۹ مهر ۱۳۹۹
<li class="nav-item dropdown">
                    <a class="nav-link" data-toggle="dropdown" href="#">
                        <i class="fa fa-bell-o"></i>
                        <ul class="notification"></ul>
                        <span class="badge badge-warning navbar-badge" id="spannoti"></span>
                    </a><ul class="dropdown-menu-noti"></ul>
</li>
<script>
$(document).ready(function(){
// updating the view with notifications using ajax
function load_unseen_notification(view = '')
{
 $.ajax({
  url:"fetch.php",
  method:"POST",
  data:{view:view},
  dataType:"json",
  success:function(data){
   $('.dropdown-menu-noti').html(data.notification);
   if(data.unseen_notification > 0){
    $('#spannoti').html(data.unseen_notification);
   }
  }
 });
}
load_unseen_notification();
// load new notifications
$(document).on('click', '#spannoti', function(){
 $('.dropdown-menu-noti').html('');
 load_unseen_notification('yes');
});
setInterval(function(){
 load_unseen_notification();
}, 5000);
});
</script>
<!-------------------fetch page------------------------------->
<?php
include "bootstrap/init.php";
global $db;
if (isset($_POST['view'])) {
if($_POST["view"] != ''){
   $update_query = "UPDATE comments SET view = 1 WHERE view=0";
   $stmt = $db->prepare($update_query);
   $stmt->execute();
}
$query = "SELECT * FROM comments  ORDER BY id DESC LIMIT 10";
$stmt = $db->prepare($query);
$stmt->execute();
$output = '';
if($stmt->rowCount() > 0){
while($rows = $stmt ->fetch(PDO::FETCH_BOTH)){
  $output .= '
  <li>
  <a href="#">
  <strong>'.$rows["title"].'</strong><br />
  <small><em>'.$rows["tozihat"].'</em></small>
  </a>
  </li>
  ';
}
}
else{
    $output .= '<li><a href="#" class="text-bold text-italic">No Noti Found</a></li>';
}
$status_query = "SELECT * FROM comments WHERE view = 0";
$stmt = $db->prepare($status_query);
$stmt->execute();
$count = $stmt->rowCount();
$data = array(
   'notification' => $output,
   'unseen_notification'  => $count
);
echo json_encode($data);
}
?>
<!--------------------------------database------------------------------------->
	id	userid	title	tozihat	active	date	view

سلام نوتیفیکیشن هست نوشتم اما کار نمیکنه راهنمایی لطفا

سلام

چه خطایی میده؟

inspector مرورگر رو باز کنید و تب console رو ببینید که آیا خطایی داره یا نه؟

لقمان آوند ۱۹ مهر ۱۳۹۹، ۰۶:۴۷