php - get a random query result and then sort it -
i need run order rand query , sort resulting info set numerically. in other words want random set of info (in case 7 numbers), need sort 7 results numerically.
after code runs:
if ($today == "oct 31") { $daylist = "halloween"; $stmt = $pdo->query("select `rand` `jukebox2014` `class` = '$daylist' order rand() limit 7"); }
i need sort 7 results.
any ideas?
thanks.
as simple as:
select `rand` ( select ... order rand() limit 7 ) order `rand`
not order rand() limit 7
rather inefficient method select random data; more efficient methods depend on exact data. search stackoverflow many questions regarding topic.
php pdo
No comments:
Post a Comment