what i want it to do is do the function on page load, the refresh the data every second, i have messed about with the code but cannot seem to get it to do what i want...it loads the function fine on page load, but it wont refresh...
can some one please help me with this.
Code:
<?php
include('connect.php');
$con = mysql_connect("$server","$user","$pass");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$db", $con);
$sql="SELECT * FROM users WHERE accessid = ".$_GET['user'];
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
?>
<body onload="showDetails(<?php echo $row['username']; ?>)" />
<script type="text/javascript">
var xmlHttp
function showDetails(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="userinfo.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==1)
{
document.getElementById("txtHint").innerHTML=="Loading";
}
if (xmlHttp.readyState==4)
{
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;
}
setTimeout("showDetails(<?php echo $row['username']; ?>)", 100);
</script>
<span id="txtHint">
</span>
<?php
}
mysql_close($con);
?>
Last edited by Vinny69; 02-25-2009 at 04:52 PM.
Reason: i had body onclick not body onload...i changed it and forgot to change it back...
In your setTimeout function you set the number of milliseconds to 100 which equates to .1 seconds. You need to tack on one more zero for it to work every second. I am not 100% sure if that is the problem.
"Hippies.They're everywhere. They wanna save the earth, but all they do is smoke pot and smell bad."-Cartman
i put a php RAND() code in the data and i just figured out that the script is only refreshing the data once, i want it to continue refreshing so that the data is up to date...
i know this is possible as Windows live profiles use it, i just cannot figure it out
hi again,
how would i go about adding a bgsound when the data changes,
but to only play once onChange
i am using this script for my web messenger and i need it for when people sign in
i have th folowing statuses:
online
busy
away
offline
i only want the sound to play when the user signs in.
even if they sign in as away or busy.
but i dont want the sound to replay every time the user swiches between these statuses
Bookmarks