On 3/13/07, Bruce Gilbert <webguync@xxxxxxxxx> wrote:
I stumbled upon this article http://www.chrisjdavis.org/2005/10/16/php-in-css/ and was trying out variables with PGP, but can't get it to work. I wanted to have a variable image that changes on refresh, and also set the body color with PHP/CSS and maybe get that to change on refresh too. sp from the tutorial mentioned above I have: [php] *snip* [/php] *snip* in my directory, I have a folder called images which is at the root level with the index file and css, and the images are called side_image1, side_image2, side_image3 etc. can anyone see whay this isn't working? Neither the background body color or the rotating image works. thanks -- ::Bruce::
*I did not read your full email, sry... But i think you are not right using PHP in this case, or atleast not in this way. There are 2 ways to solve this quite easy 1) use javascript to randomly select a image from a predefined array. example: <SCRIPT LANGUAGE="JavaScript"> var theImages = new Array() theImages[0] = 'images/001.png' theImages[1] = 'images/002.png' theImages[2] = 'images/003.png' theImages[3] = 'images/004.png' theImages[4] = 'images/005.png' theImages[5] = 'images/006.png' theImages[6] = 'images/007.png' theImages[7] = 'images/008.png' theImages[8] = 'images/009.png' theImages[9] = 'images/010.png' theImages[10] = 'images/011.png' theImages[11] = 'images/012.png' theImages[12] = 'images/013.png' theImages[13] = 'images/014.png' theImages[14] = 'images/015.png' theImages[15] = 'images/016.png' theImages[16] = 'images/017.png' theImages[17] = 'images/018.png' theImages[18] = 'images/019.png' theImages[19] = 'images/020.png' theImages[20] = 'images/021.png' theImages[21] = 'images/022.png' theImages[22]= 'images/023.png' theImages[23] = 'images/024.png' theImages[24] = 'images/025.png' theImages[25] = 'images/026.png' var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } </script> 2) or you could generate the images with PHP so you would call your image with <img src="http://server.com/myimage.php"> (or maybe from CSS. and your myimage.php would contain something like <?php $image[0] = "images/1.jpg"; $image[1] = "images/2.jpg"; $image[2] = "images/3.jpg"; $image[3] = "images/4.jpg"; $image[4] = "images/5.jpg"; $image[5] = "images/6.jpg"; $image[6] = "images/7.jpg"; $image[7] = "images/8.jpg"; $image[8] = "images/9.jpg"; $image[9] = "images/10.jpg"; $rand = rand(0,9); $contents = file_get_contents($image[$rand]); header("Content-Type: image/jpeg"); imagejpeg($contents); ?> And that should do the same Tijnema ps. I've written both codes out of my head, i didn't test so there might be typo's... $
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php