You are on page 1of 2

04/01/2021 Facebook Like Header Notification in PHP - Phppot

helping build websites Shop Services Testimonials Blog About Con

eCommerce Facebook Like Header Notification in PHP Hi, I’m Vincy. I help build websites
Components Last modified on April 6th, 2017. and I’m available for freelance work.
Files
In Facebook like social networking websites, we can see notification alert in the vincy@phppot.com
UI page header. In this tutorial, we are going to add such header notification to
Performance notify the user about latest data. This will be helpful to keep the user updated by
Contact Form - Iris
notifying what is new.
Framework

PHP In this example, we have a notification icon in the page header. We show the
notification count to represent how many new items are there as unread. On
Learn PHP
clicking the notification icon, we list the latest items.
PHP Introduction
PHP Basics
Contact Form
view demo
Comments System
Types, Variables &
Operators
PHP Strings
PHP Arrays
PHP Functions
PHP OOPS
“From the beginning of the revision Vincy
PHP Forms
hands-on, providing constructive critiques
Advanced how to best make our system more efficie
PHP AJAX and streamlined. After her full analysis of
Country-State-City code structure ...” read more
Example: Cascading
jQuery AJAX Steve Kalinowski, CatechismClass.com,
Dependent Dropdown
in PHP
Load Dependent
Dropdown on Multi-
Select using PHP and
jQuery
AJAX Based Login
Registration System
with jQuery Lightbox
Create AJAX-Based
PHP Event
Management System
with Bootstrap Posting New Data to Notify
How to Create
Facebook Like Infinite This code shows an HTML form to post a new message to be notified to the
Scroll Pagination using
PHP and jQuery
user. After submitting this new message it will be stored in a database with the
Facebook Like Header
‘read’ status 0. The messages with the read status 0 are unread messages. The
Notification in PHP sum of the unread messages is calculated and displayed near to the notification
Sorting MySQL Row icon in the header.
Order using jQuery
AJAX Pagination with <?php
PHP $conn = new mysqli("localhost","root","","blog_samples");
$count=0;
Change Order of
if(!empty($_POST['add'])) {
Images in Photo
$subject = mysqli_real_escape_string($conn,$_POST["subject"]);
Gallery with Drag and
$comment = mysqli_real_escape_string($conn,$_POST["comment"]);
Drop using PHP AJAX
$sql = "INSERT INTO comments (subject,comment) VALUES('" . $su
PHP AJAX mysqli_query($conn, $sql);
Programming }
$sql2="SELECT * FROM comments WHERE status = 0";
PHP Star Rating
$result=mysqli_query($conn, $sql2);
System with JavaScript
$count=mysqli_num_rows($result);
Events Display using ?>
PHP AJAX with CLNDR <form name="frmNotification" id="frmNotification" action="" method="po
Calendar Plugin <div id="form-header" class="form-row">Add New Message</div>
<div class="form-row">
RESTful API <div class="form-label">Subject:</div><div class="error" id="su
PHP Databases <div class="form-element">
<input type="text" name="subject" id="subject" required>
PHP Sessions and
Cookies </div>
Error and Exception </div>
Handling <div class="form-row">
<div class="form-label">Comment:</div><div class="error" id="co
File Upload <div class="form-element">
Files and Directories <textarea rows="4" cols="30" name="comment" id="comment"></

PHP Date Time


PHP XML
PHP Code Samples Show Notification Data using jQuery
Library
More PHP

https://phppot.com/php/facebook-like-header-notification-in-php/ 1/2
04/01/2021 Facebook Like Header Notification in PHP - Phppot
PHP Freelancer We call a jQuery script on the click event of the notification icon. In this jQuery
script, we call PHP via AJAX to get latest messages from the database.

On clicking notification icon, it removes the notification count from header and
list all the latest data. The script is,

<script type="text/javascript">
function myFunction() {
$.ajax({
url: "view_notification.php",
type: "POST",
processData:false,
success: function(data){
$("#notification-count").remove();
$("#notification-latest").show();$("#notification-latest
},
error: function(){}
});
}

$(document).ready(function() {
$('body').click(function(e){
if ( e.target.id != 'notification-icon'){
$("#notification-latest").hide();
}
});
});
</script>

view demo download

Popular Articles
★ PHP AJAX Programming
★ Create AJAX-Based PHP Event Management System with Bootstrap
★ PHP Star Rating System with JavaScript

Search articles

↑ Back to Top

Looking for a freelance web developer?


Do you want to build a modern, lightweight, responsive website and launch quickly? Contact Me

Blog subscription:

Enter your email here Subscribe

Shop

FAQ Support Policy Refund Policy Licenses


Terms of Service Privacy Policy Cookie Policy © 2020 Phppot

https://phppot.com/php/facebook-like-header-notification-in-php/ 2/2

You might also like