How to create a notification system similar to facebook

Asked

Viewed 8,886 times

1

I am beginner and need to develop a system for task control in php. I would like this system to have an icon in the upper right corner, which would show a number of expired/expired tasks that day to the user, similar to facebook.

Is there anything ready you can use?

  • What did you try?

  • In this video you have a php + javascript solution that may be useful https://www.youtube.com/watch?v=CFFJeHw6VBU. This question here at Sopt may also be useful http://answall.com/questions/9475/notifies%C3%A7%C3%B5es-real-time-like-to-stack-overflow.

1 answer

4


I tested the code and it’s working. Any questions just ask.

index.php

!DOCTYPE html>
 <html>
 <head>
    <title></title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>     
        <script type="text/javascript">
        function atualizarTarefas() {
           // aqui voce passa o id do usuario
           var url="get.php?id=1";
            jQuery("#tarefas").load(url);
        }
        setInterval("atualizarTarefas()", 1000);
        </script>   
 </head>
 <body>
INFORMACAO EH EXIBIDA AQUI: <div id="tarefas"></div> 
 </body>
 </html>

get.php

<?php 
    $con = mysqli_connect('localhost', 'root', '', 'tarefas');

    $id = $_GET['id'];

    $sql = "select * from tarefas where id = $id";

    $query = mysqli_query($con, $sql);
    $resultado = mysqli_fetch_assoc($query);

        $retorna = $resultado['vencidas'];
        echo $retorna;
?>
  • 1

    [...]tarefas vencidas/vencem naquele dia... Make requests to verify tasks that have won or will win on the day is an exaggerated waste. If the user has logged in in the morning and there is no notification, the next check will be at the end of the day, not the next second!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.