dimanche 19 avril 2015

Check Variables of different scripts to match in PHP

Hi there I have an idea and I don't know if its possible to work it out but Ive got few different methods for it and I don't know which one to pick and which one will work better but Here is what I have:





//##CHAT.php
$sqlmessages = mysql_query("SELECT * FROM chat");
$numbermessages = mysql_num_rows($sqlmessages);
session_start();
$_SESSION['chatnum'] = $numbermessages;



//##checkanynewmessages.php
$url="checkanynewmessages.php";
header("Refresh: 5; URL=$url1");
$oldmessages = $_SESSION['chatnum'];
$sql1messages = mysql_query("SELECT * FROM chat");
$newnumchat = mysql_num_rows($sql1messages);
if($oldmessages===$newnumchat) {
//do nothing
} else {
//it should refresh the chat.php because its required in the page
echo "<script>window.location = window.location.href;</script>";
}



And the other solution would be if I figure out how AJAX or Javascript or JQuery would refresh the page if It could check for the mysql table but I don't know how its done in those languages ... thanks!


Aucun commentaire:

Enregistrer un commentaire