PDA

View Full Version : Refreshing Data from MySQL DB in PHP


Truffle
02-03-2006, 03:26 AM
I have this one little page that sits in a frame on the side and it's only purpose is to display names that have a status of 'Y'. The status can change between Y and N at any time so I thought it should refresh itself, or update, every few seconds


<body bgcolor="black" text="white">
<?
include("db.php");
$sql = "SELECT `user` FROM `login` WHERE `status` = 'Y'";
$query = mysql_query($sql) or die(mysql_error());
while($data=mysql_fetch_assoc($query)){
echo $data['user']."<BR>";
}
?>
</body>


My first method, which works, was just to use the meta refresh tag. The only problem is that in Internet Explorer it makes an annoying click sound every 5 seconds (when it refreshes).

Only other option that I'm aware of is using an AJAX method, which I don't even know where to start.

So, how can I requery "SELECT `user` FROM `login` WHERE `status` = 'Y'" every 5 seconds without having to reload the entire page? Can someone point me in the right direction?

Thanks