Question: I have an employees table here to see whether they are in the office or out. I have a php file to select the status from the database. I tried changing the status from out to in and in to out in the database but I cannot see any changes in my php page until I reload it. How can I get my php page change automatically when there is a change in the database?? I m a newbie so please help out... Thanks in advance. I have the php file here:

```
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'pass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT Name,Status FROM Employees';

mysql_select_db('new');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
    echo "Name :{$row['Name']}  <br> ".
         "Status: {$row['Status']} <br> ".
         "--------------------------------<br>";
} 
echo "Fetched data successfully\n";
mysql_close($conn);
?>

```

Answer: 
If you really want this, you can do an ajax request every say 5 seconds, send the old values with the request and compare them to the database, if there is a difference you trigger a refresh, this way you only refresh your page when there is an actual update. (or you just update it using ajax every 5 seconds, looks a lot cleaner than a full page refresh)

Both require polling though, there is no easy way to do it without just checking every so many seconds.
Use the below mysql 

```
 while($row = mysql_fetch_array($retval))
    {
        echo "Name :{$row['Name']}  <br> ".
             "Status: {$row['Status']} <br> ".
             "--------------------------------<br>";
    }

```