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();

4
2
Awgiedawgie 440220 points

                                    <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>

4 (2 Votes)
0
4
3
Phoenix Logan 186120 points

                                    <script type="text/javascript">

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

</script>

4 (3 Votes)
0
4.11
9
Awgiedawgie 440220 points

                                    <li class="dropdown dropdown-extended dropdown-notification dropdown-dark" id="header_notification_bar">

                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
                                    <i class="icon-bell"></i>
                                    <span class="badge badge-success"><div id="datacount"></div></span> </span>
                                </a>
                                <ul class="dropdown-menu" >
                                    <li class="external">
                                        <h3>
                                            <span class="bold">12 pending</span> notifications</h3>
                                        <a href="page_user_profile_1.html">view all</a>
                                    </li>
                                    <li>
                                        <ul class="dropdown-menu-list scroller" style="height: 250px;" data-handle-color="#637283">
                                            <li>
                                                <a href="javascript:;">
                                                    <span class="time">just now</span>
                                                    <span class="details">
                                                        <span class="label label-sm label-icon label-success">
                                                            <i class="fa fa-plus"></i>
                                                        </span> New user registered. </span>
                                                </a>
                                            </li>

                                        </ul>
                                    </li>
                                </ul>
                            </li>

4.11 (9 Votes)
0
4
7
Phoenix Logan 186120 points

                                    <?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);
}
?>

4 (7 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
php mysql js create notification notification system php ajax bootstrap notification in php ajax result notification system with php php ajax notification system php live notification system ajax notifiy in html PHP tools for notifications using MySQL why notic show in php html php notification system how to add notification in html php notification system in php how to make notification in php notification generate in website when data inserted post notice on homepage using php and mysql php page update notification server down notification php notification message using php and jquery free php mysql real time update php notification button on website like facebook PHP REALTIME NOTIFICATIONS WITH AJAX nulled php instant notifications ajax notification download notificaton system create notification php instant notification php code php update notification simple live notifications in jquery ajax php mysql ajax notification php live notifications in jquery ajax laravel mysql live notification ci Realtime Live Notification Count Like Facebook | PHP | AJAX | JAVASCRIPT codeigniter Realtime Live Notification Count Like Facebook | PHP | AJAX | JAVASCRIPT how to use show notifications php live notifications in jquery ajax php mysql php notification class clock notification php javascript php un notification notifications in php php mysql user notification create a simple notifications api in php for my app create a simple notifications api in php create a notifications api in php Push notification in PHP -youtube.com -soundcloud.com -residentadvisor.net -djtunes.com -junodownload.com -itunes.apple.com -beatport.com -trackitdown.net -djDownload.com -mixcloud.com -last.fm -traxsource.com how to get notification from php how to make an alert for a new record in php php notification count how to create notification dropdown list in php php ?? creating notices notification ajax php mysql php notify javascript php code for notification system using mysqli php code for notification system noticfation system php notification system php php notifications create a notification system html notification php php notification usin ajax with php notification php notification tutorial how to send a notification on php social media bell notification function in php notification bell function in php php notification system bell notification on new order in php push notifications system php push notification database ajax database notification in php demo ajax notification popup example php form insert to database and give notification php mysql notification system notification in php systeme de notification php mysql php page notification php jquery notification popup Sending Emails with Node.js Using SMTP, Gmail, and OAuth2 message cloud with android and php cloud message service android and php sql without FirebaseInstanceIdService how to alert message in php how to force browser to update js and css files cache after deploy notification message in html personal chat using jquery and php mysqli event calendar with php & mysql get fb notifications using graph api and python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source