I have a table where I store ads I have 20 of them here! I would like to show 10 ads at the site on the page. How can I randomly select and output 10 threads from a table that contains many of them!

If the are less than 10 threads then show all of them randomly rotating if more than 10 then randomly select 10.

If there’s less then 10 you could use shuffle() on the result set. If you’ve got more then 10 then select them all and then use array_rand() to pick 10 (or however many you need) at random from the result set.

btw: @rpkamp do you still have the test data available from that thread to recreate the graphs? @ralphm do you know if all attachments from the vBulletin days still exist? If so the graphs could be extracted from the vBulletin version of the thread and added to the Discourse version of the thread. @Ophelie might be worth being the subject of an PHP article comparing the different methods of getting a certain number of random entries from a database table