I’m trying to create a background switcher, but I’m unsure as to what approach I should take. I’m trying to avoid multiple style sheets, so should I maybe use uri segments and a redirect to referrer? or use a form for each item and make the anchor for each thumbnail the submit button sending a hidden id to php?
Also I’m aiming to store some meta data for each background in a db, so I could pull information such as the artist or the name of the background from the db.
I’m just stuck, can someone give me a nudge? Please and thank you [:
Here's what I used.
<?php
$backgrounds = array();
foreach(scandir('images/') as $file)
if(strpos($file, '.png')||strpos($file, '.jpg')||strpos($file, '.jpeg'))
array_push($backgrounds, $file);
shuffle($backgrounds);
?>
<img id="bg" src="images/<?php echo $backgrounds[0]; ?>" />
And the CSS:
#bg{
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
position: absolute;
}
This creates a scaling background which is completely random among all the images in the "images" folder.
I'm off to school, so I don't have time to modify it for your purposes, but maybe this will give you the nudge you've been looking for.