Pick x number of rows from mysql table and display with php
i am currently designing the welcome page for my website and i would like to display random images from my database on the home screen.
i have many images stored in my database and each time someone visits the site i would like 4 random pictures to be selected from my db and displayed. i have heard about the rand() php function but heard that for large databases this is a bad one to use.
i really am stumped on this, thanks in advance to anyone who can help :):confused:
"large" means hundreds of thousands or millions of records.
I doubt seriously that you have that many images in use.
I would feel comfortable using RAND() with up to a few thousand records, though if your tables are "wide" (that is, if there are many many fields in each row of the table) there are some tricks you might want to use to improve the efficiency of your queries.
For example, if you have an ID column as your PRIMARY KEY, you could do:
|All times are GMT +1. The time now is 11:13 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.