Displaying Notification when new data is entered by admin into the table.

ref: http://ned.im/noty/

i m trying to use this design.
but how do we trigger? i building site using dw c6. have complete knowledge in html & bit about php.

site is built on php & html.
 so how can we trigger when new data is entered in certain table?
Mohammed KumelAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

How does data get written to the "certain table"? Is it through you app as well? If it is, then I suggest this approach:

You want notifications to happen in real time. So a user might be working on whatever else, BUT once that data is written into the table, you want them to get a notification saying data has been written to the database.
You want the web server to push the message to all the users.
One of your pages is responsible for writing data to the table

Approach: WebSockets
References: http://www.bennadel.com/blog/2351-coldfusion-10---using-websockets-to-push-a-message-to-a-target-user.htm, http://en.wikipedia.org/wiki/Web_socket

Server Side:
1 - Create your web sockets infrastructure (the posted article is well documented and available on GitHub)
2 - In your page where records are written to the table (on each successful INSERT/UPDATE or whatever), use the web socket to broadcast a message to all connected users

Client Side:
3 - Add the noty infrastructure (javascript + css references etc). This is detailed on the noty page.
4 - Add code which establishes a channel connection (ideally to each page that may received messages). Depending on your page structure, the best place to add this is to a header/footer section which gets included on all your pages in the site. So that there is only one place to maintain this.
5 - In the socket.on (http://www.bennadel.com/blog/2351-coldfusion-10---using-websockets-to-push-a-message-to-a-target-user.htm => main.js line 42) instead of writing the message to the console (console.log( "Published:", data );) you issue a noty (var n = noty({text: data});)

NOTE: Of course if users are not logged on OR they are busy doing a page refresh they will miss any notifications :) We are not caching notifications on the server side or anything fancy like this. This is 100% real time.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mohammed KumelAuthor Commented:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<div id="result"></div>

<?php include 'Connections/con1.php';?>

      var source = new EventSource("demo_sse.php");

    document.getElementById("result").innerHTML+=event.data + "<br>";
  document.getElementById("result").innerHTML="Sorry, your browser does not support server-sent events...";

Open in new window


include 'Connections/con1.php';
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');
mysql_select_db($database_con1, $con1);
$query_Areas = "SELECT * FROM Areas";
$Areas = mysql_query($query_Areas, $con1) or die(mysql_error());
$row_Areas = mysql_fetch_assoc($Areas);

<!-- codes for displaying data goes here -->


Open in new window

When new records are added here i want it to show as notification.
Table Areas got following columns:

Mohammed KumelAuthor Commented:
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_con1 = "localhost";
$database_con1 = "lotomanager";
$username_con1 = "root";
$password_con1 = "";
$con1 = mysql_pconnect($hostname_con1, $username_con1, $password_con1) or trigger_error(mysql_error(),E_USER_ERROR);

i want it to work on php & nothing else.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Oh dear! i wonder why I was thinking ColdFusion and not PHP! You clearly state that it's PHP! I'll find some PHP examples for you. The model I propose still works, just  a different language.
Mohammed KumelAuthor Commented:
waiting eagerly. :(
Here is a sample:


It would be good if you worked through that and familiarised yourself with the idea. Then see if you can implement this in your app.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.