Forum Moderators: coopster
In your css or html or wherever you specify the background for the page, do something like
background-image:url(<?php echo $bg?>.jpg);
So the browser will load whatever background corresponds to the random number PHP made up.
$ext = array("pic1.jpg", "pic2.jpg", "pic3.jpg"); //etc
shuffle($ext); //Give the array a shuffle
background-image:url('images/<?php echo $ext[0];?>');
This would display the data in the first slot. File extensions might be better as you could loop through your images directory and assign the extensions to an array there, then add new ones if you wish.
Hope that helps.
<style type="text/css" media="all">
body {color: #000; background: transparent; background-image: url('./dir/<?php echo $ext[0];?>');
}
</style>
#########################
Error mesage is
#########################
Parse error: parse error, unexpected T_VARIABLE in /dir/folder/page.php on line 4
##################
Can Anyone tell me what im doing wrong to get the random backgrounds showing on the pages. I have even read my php book and this is also the same coding it shows or close to it
pat