A script I've inherited is showing a random image on the homepage. The random image is currently determined (ugh) by grabbing an array of all of the images, then
$rand_keys = array_rand($array_photoid, 2);
$photoid = $photo_rows[$rand_keys[0]];
No doubt this worked swell when there were only a few dozen images, but now there are 5000 and this needs fixing.
While rewriting this I'd like to add in some functionality that allows users to go to the Previous and Next image. Going forward is easy enough, just draw up another random ID from the table.
How would I allow users to go back over previously shown random images? Is this even possible without resorting to a hack like above (storing all id's in a session array).