query("select count(*) as nb from t_notification where status is null AND roles = ".$_SESSION['ROLES']); $r = $q->fetchAll()[0]; echo $r['nb']; } else { // otherwhise you want to load the info about the newest notification to display and set the status to 1 so it wont be displayed again $q = $db->query("select * from t_notification where status is null AND roles = ".$_SESSION['ROLES']." order by id limit 1"); $r = $q->fetchAll()[0]; $db->query("update t_notification set status = 1 WHERE roles = ".$_SESSION['ROLES'].""); echo $r['info']; } ?>