Suppose we have the following code to list the users who are subscribed to my page.
<?php
public static function registrados($usuario){
$query = "SELECT * FROM usuarios where nombre = :nombre and apellido = :apellido";
self::getConexion();
$resultado = self::$cnx->prepare($query);
$resultado->bindValue(":nombre", $usuario->getnombre());
$resultado->bindValue(":apellido", $usuario->getapellido());
$resultado->execute();
if($resultado->rowCount() > 0){
$filas= $resultado->fetch();
if($filas["nombre"]==$usuario->getnombre() && $filas["apellido"] == $usuario->getapellido()){
return true;
}
}else{
return false;
}
?>
I want that if an update or a data insertion is made from another part, the information is updated, and it is displayed on the screen.
I know there is a way to do it with jquery, in an asynchronous way... But, I don't know of an example or a code that explains how to do it, as in this simple case, in which I only need to show the information on the screen the first and last name of a user who has subscribed to a page...
I took as a reference the status of a person on twitter. Every time that person posts a new tweet, it gets stacked on the list as first. And so it happens instantly on the screen of other users who follow it, without having to press F5 to refresh the page and see the latest events published by the person.
You can use an Interval that from time to time is calling your php function