Seems simple enough right? I have put many hours into a solution...and nothing. I have tried multiple scripts and codes. Finally, I decided to ask for help.
Here is the background...
- PHP web site
- Homepage shows images from database
- Images are pulled randomly and displayed on homepage
- New image each time page is refreshed
My needs...
- To continue to pull images from the database at random, AND...pull a new random image from the database every 10 seconds even if the page is not refreshed.
Makes sense? Here is my code:
<?
$dbhost = "blah blah blah";
$dbuname = "blah blah blah";
$dbpass = "blah blah blah";
$dbname = "blah blah blah";
$link = mysql_connect($dbhost, $dbuname, $dbpass);
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db($dbname);
$q="select * from `site_cars` order by RAND() limit 1";
$r=mysql_query($q);
if(!$r)
{
echo mysql_error();
}
while($row=mysql_fetch_array($r))
{
?>
<a class=toggleopacity href="details.php?id=<?=$row['car_id']?>"><img src="upload/car_<?=$row['car_id']?>" width="625" height="370" border="0"></a>
</p>
<?
}
?>
The above code goes into the database. Pulls and displays one car from the database at random. The image of the car is displayed each time the page is refreshed. That's fine. I simply want to "refresh" the image every 10 seconds. I only want to refresh the image, not the entire page.
Can someone guide me in the right direction? Greatly appreciated!