Perhaps I'm going about this the wrong way or maybe it's not possible. I have a php select statement within a javascript function. I am trying to refresh the php statement by refreshing javascript function that it is contained in by using window.setInterval("getServerText()",5000);. The result I am looking for is to refresh the php statement every 5 seconds for the php conditional statement I have afterwards. This conditional statement contains two seperate url's that I am trying to call up dependant upon the result of the PHP statement. The script works initially and brings up the results of the first condition, but upon refreshing it seems that the php script doesn't execute again and I am always receiving the same results. Below I supplied the basics of the code I am using and removed anything before or after that I felt would only confuse anyone looking at this. Thanks in advance for any help.
<script type="text/javascript">
function getServerText(){
<?
$sql = mysql_query("select whatever from table where something = '$something'");
while ($row = mysql_fetch_array($sql)) {
$whatever = $row['whatever'];
}
if($whatever == 'whatever'){
$url = 'http://mydomain.com/something.php';
}else{
$url = 'http://mydomain.com/something_else.php';
}
?> var myurl = "<?= $url ?>";
myRand = parseInt(Math.random()*999999999999999);
var modurl = myurl+"?rand="+myRand;
http.open("GET", modurl, true);
http.onreadystatechange = useHttpResponse;
http.send(null);
}
</script>
<script type="text/javascript">
<!--
window.setInterval("getServerText()",5000);
//-->
</script>