Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to build jquery messages notification with php and mysq

$sql = "update tbl_noti set status = 'read'";
       $result = $conn->query($sql);
       $row = $result->fetch_assoc();
       $count = $result->num_rows;
       echo $count;
       $conn->close();
Comment

how to build jquery messages notification with php and mysq

<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').html(data.notification);

   if(data.unseen_notification > 0)
   {
    $('.count').html(data.unseen_notification);
   }

  }

 });

}

load_unseen_notification();

// submit form and get new records

$('#comment_form').on('submit', function(event){
 event.preventDefault();

 if($('#subject').val() != '' && $('#comment').val() != '')

 {

  var form_data = $(this).serialize();

  $.ajax({

   url:"insert.php",
   method:"POST",
   data:form_data,
   success:function(data)

   {

    $('#comment_form')[0].reset();
    load_unseen_notification();

   }

  });

 }

 else

 {
  alert("Both Fields are Required");
 }

});

// load new notifications

$(document).on('click', '.dropdown-toggle', function(){

 $('.count').html('');

 load_unseen_notification('yes');

});

setInterval(function(){

 load_unseen_notification();;

}, 5000);

});

</script>
Comment

how to build jquery messages notification with php and mysq

<script type="text/javascript">

$(document).ready(function(){
$("#datacount").load("select.php");
setInterval(function(){
$("#datacount").load('select.php')
}, 20000);
 });

</script>
Comment

how to build jquery messages notification with php and mysq

<?php

include('connect.php');

if(isset($_POST['view'])){

// $con = mysqli_connect("localhost", "root", "", "notif");

if($_POST["view"] != '')

{
   $update_query = "UPDATE comments SET comment_status = 1 WHERE comment_status=0";
   mysqli_query($con, $update_query);
}

$query = "SELECT * FROM comments ORDER BY comment_id DESC LIMIT 5";
$result = mysqli_query($con, $query);
$output = '';

if(mysqli_num_rows($result) > 0)
{

while($row = mysqli_fetch_array($result))

{

  $output .= '
  <li>
  <a href="#">
  <strong>'.$row["comment_subject"].'</strong><br />
  <small><em>'.$row["comment_text"].'</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 comment_status=0";
$result_query = mysqli_query($con, $status_query);
$count = mysqli_num_rows($result_query);

$data = array(
   'notification' => $output,
   'unseen_notification'  => $count
);

echo json_encode($data);
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: how to delete php from win10 
Php :: php or 
Php :: wordpress post revisions config 
Php :: laravel model created_at format edit 
Php :: php isset multiple 
Php :: csv to array php 
Php :: php const 
Php :: Flutter Error - Migrate to android studio - MAC OS 
Php :: how to use postgresql with laravel 
Php :: select query in php 
Php :: laravel insert timestamp now 
Php :: laravel image ratio validation 
Php :: Convert String to Date and Date-Time in PHP 
Php :: iterate through an associative array php 
Php :: php date object to timestamp 
Php :: calculate 18 years back date in php 
Php :: laravel check empty string 
Php :: php required 
Php :: get month first date and last date in php 
Php :: how to echo only certain character number in php 
Php :: pass in php 
Php :: utf8 php 
Php :: php flatten multidimensional array 
Php :: how to remove null values in array php 
Php :: laravel 8 route 
Php :: laravel get image extension 
Php :: php cut string 
Php :: php catch all exceptions 
Php :: Clear from faild_jobs laravel 
Php :: laravel fixed character limit 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =