I have a database of facts and I want to display one of these facts at random for say 10 seconds then for it to choose another fact and display it for 10 seconds and so on.
Currently I can get it to display a random fact fine using the code below however I am a bit confused about how to show this for 10 seconds and then display a different fact. Any help or advice would be brilliant? Thanks.
<?php
$linkid = $_GET['linkID'];
$query = "SELECT *
FROM facts
ORDER BY RAND()
LIMIT 1";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$factxt = $row ['factxt'];
echo $factxt;
}
?>
Hi, ok I tried both of the ways suggested below, using ajax and jquery but both are returning the same error from the database:
Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in getfact.php on line 4
This is line 4 of getfact.php,$query = "SELECT * FROM facts order by rand() limit 1";
$result = mysql_query($query);
is there something that I am doing wrong?