Ciao a tutti, come faccio a fare in modo che la query SQL venga eseguita ogni tot secondi?
Qui sotto posto il mio codice
codice:
=============ajax.js=============
var xmlHttp
function showUser(str){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="provastringaperajax.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject(){
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
codice:
<html>
<head>
<script src="ajax.js"></script>
</head>
<body onLoad="showUser('ciao');">
</p><div id="txtHint"></div>
</p>
</body>
</html>
Codice PHP:
=============provastringaperajax.php=============
<?
include "../config.inc.php";
$sql = "SELECT FUNZIONE FROM FUNZIONI";
$query = mysql_query($sql,$connessione) or die(mysql_error());
while ($row = mysql_fetch_array($query)){
echo $row["FUNZIONE"]."
";
}
?>
grazie mille in anticipo