but that just gets the first record each time when i run it..
If you are having problems with RAND() from SQL, you could do:
$result = mysql_query("SELECT COUNT(id) FROM tblbannerimages");
$row_count = mysql_result($result, 0);
if ($row_count > 0) {
$randnum = mt_rand(0, $row_count - 1);
$result = mysql_query("SELECT imagename FROM tblbannerimages LIMIT $randnum, 1");
echo mysql_result($result, 0);
} else {
echo 'No rows retrieved';
}
If ORDER BY RAND() randomises the entire potential result set, this may actually be faster. On the other hand, this uses two queries, and we normally prefer to minimise I/O, especially since there is the possibility of a race condition happening between queries and changing the number of rows in the table.