I have a table of about 500 records. I'm trying to build a page that randomly gets 5 unique rows at a time and displays all 5 on the page at the same time, in a list. My code is below. I can get it to display the random result but only one record at a time. I need it to display all 5. Thanks for your help.
<ul>
<?php
$query = mysql_query("SELECT * FROM listings WHERE inactive='0' and approved='1' ORDER BY RAND() LIMIT 5");
$result = $query;
while ($row = mysql_fetch_array($result)) {
echo ("<li>" . $row["title"] . "</li>");
}
?>
</ul>