Instead of looping through all results and then picking a random one, you can let MySQL do the job:
SELECT * FROM table ORDER BY RAND() LIMIT 1
pritaeas
Posting Prodigy
9,265 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,456
Skill Endorsements: 86
If I understood you can also replace previous $random_id array_rand() and implode() with:
$random_id = shuffle($id); # or you can use array_rand($id,1);
$sql1 = "SELECT * FROM table WHERE id = '$random_id[0]'";
and if you want one single result from the query then add limit 1 at the end, bye.
cereal
Veteran Poster
1,144 posts since Aug 2007
Reputation Points: 344
Solved Threads: 222
Skill Endorsements: 22