Random pictures with background: link to a random image php script - simpler and better way

advertisements

I know there has to be a better way to do this.

Currently I have a php script which will generate a random image from a certain directory when called.

I have div's calling the background.php file in the stylesheet under the div's background setting

background:url(randomimagescript.php);

There are a lot of little div's on this page right now, all calling separate random image php scripts... is there a way I could use a variable when calling the file, so I can just use one script? I still need to have good styling control over the image, so i'm not sure if there is a better option than calling the script as a background image for a div.

If anyone has any ideas, let me know!


try this (it might not be optimal):

background:url("randomimagescript.php?folder=myfolder");

and in randomimagescript.php:

<?php
    $folder = @_$REQUEST['folder'];
    $url = "galleries/$folder/thumbs/image.jpg";  // ie, compose image
    http_redirect($url);  // go and find the image.
?>