I want it to be able to rotate between 3-5 images with a text description. Ideally just something basic like xml or text file as for the time being it doesnt need to be mysql. Cheers
Have you looked at PHP using random() to pick 1-X and then switch to load the random pick? No mysql involved. Just 3-4 lines of code per pick.
Thats a nice simple script, I have 2 questions, how do i customise it to add the comment and is there a way to ensure the picture only displays at a certain size?
To add the comment, (slightly modified from the original) // array of images $image_db = array( 1 => 'link_to_picture_1', 'link_to_picture_2', 'link_to_picture_3', 'link_to_picture_4', 'link_to_picture_5', ); // array of comments $comment_db = array( 1 => 'COMMENT_FOR_IMAGE_1', 'COMMENT_FOR_IMAGE_2', 'COMMENT_FOR_IMAGE_3', 'COMMENT_FOR_IMAGE_4', 'COMMENT_FOR_IMAGE_5', ); // generate a random number $rand = rand(1,count($image_db)); // finally, print image print '<img src="' . $image_db[$rand] . '" />'; // print comment below it print '<br />'.$comment_db[$rand]; PHP: Regarding this what you mean was limiting the size of the image?
$height_width_limit = '200'; // array of images $image_db = array( 1 => 'link_to_picture_1', 'link_to_picture_2', 'link_to_picture_3', 'link_to_picture_4', 'link_to_picture_5', ); // array of comments $comment_db = array( 1 => 'COMMENT_FOR_IMAGE_1', 'COMMENT_FOR_IMAGE_2', 'COMMENT_FOR_IMAGE_3', 'COMMENT_FOR_IMAGE_4', 'COMMENT_FOR_IMAGE_5', ); // generate a random number $rand = rand(1,count($image_db)); // finally, print image print '<img src="' . $image_db[$rand] . '" '; $img_size = getimagesize($image_db[$rand]); if ($img_size[0] > $height_width_limit || $img_size[1] > $height_width_limit) { // either width or height is bigger than $height_width_limit set above // let the browser do proportional resizing itself if ($img_size[0] > $img_size[1]) { // width > height , limit the size using width print 'width="'.$height_width_limit.'px" '; } elseif ($img_size[1] >= $img_size[0]) { // height > width , limit the size using height print 'height="'.$height_width_limit.'px" '; } } // close img tag print '/>'; // print comment below it print '<br />'.$comment_db[$rand]; PHP: Anyway, whats the shape of the image? square? rectangle? its width greater than height or?