SELECT *
FROM pressreleases
ORDER BY RAND() LIMIT 8
Which takes 8 random press releases, which is great, however i would like to change it so it selects the 8 lastest press releases, (it has a "orderdate" column with unix timestamps), then sorts them in a random order.
<?php
mysql_select_db($database_keenandb, $keenandb);
$query_stringwalk = "SELECT * FROM (SELECT * FROM pressreleases as pr ORDER BY orderdate DESC LIMIT pr_rand ORDER BY RAND()";
$stringwalk = mysql_query($query_stringwalk, $keenandb) or die(mysql_error());
$row_stringwalk = mysql_fetch_assoc($stringwalk);
$totalRows_stringwalk = mysql_num_rows($stringwalk);
?>
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM pressreleases as pr ORDER BY orderdate DESC LIMIT
(SELECT * FROM pressreleases as pr ORDER BY orderdate DESC LIMIT 8) ORDER BY RAND()
And it is now working beautifully. I cannot thank you enough for your help. You just saved me a long night(it will still be long, but i wont need to worry about that).