Notification system with jquery, php and mysql

HI, i’m trying to develop a notification system using jquery and php. So i’ve created a new table in the database where i’m going to store all the new notifications. Using jquery i’ve been able to show an alert (bubble icon) showing the number of new lines added to the database, but i’m now stuck because i don’t really know how to update the database (fire update.ph file) when i click the icon (.icon-bell) which does activate a dropdown menu.

Many thanks for your help guys :slight_smile:

This is the jquery script i’ve added to the index page

<script type="text/javascript">

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

</script>

This is the html code in the index page

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

This is the select.php file

$sql = "SELECT * from tbl_noti where status = 'unread'";
       $result = $conn->query($sql);
       $row = $result->fetch_assoc();
       $count = $result->num_rows;
       echo $count;
       $conn->close();

this is the update.php file

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

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.