Hey all, wondering if you could offer some advice to someone with very little experience!
I am displaying some pictures from different albums with the following:
$lpictures = $db->query(" SELECT albumpicture.*, album.*, user.username, user.usergroupid, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid FROM " . TABLE_PREFIX . "albumpicture AS albumpicture LEFT JOIN " . TABLE_PREFIX . "album AS album ON(album.albumid = albumpicture.albumid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON(user.userid = album.userid) WHERE album.state = 'public' ORDER BY dateline DESC LIMIT 0, $displayrecords ");
This displays the pictures in terms of date, the last x pictures uploaded to the gallery. I want to display a random selection of pictures.
I achieved this by changing
ORDER BY dateline DESC LIMIT 0, $displayrecords
ORDER BY rand() DESC LIMIT 0, $displayrecords
Using rand() seems to be frowned upon by developers, and a total dead-end when you try to use it on a large table. I clearly want anything to run as smoothly as possible, but don't know any alternatives besides rand() maybe you could help me out?