View Single Post
Old 12-22-2012, 04:41 PM   PM User | #2
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
Hi,

If you're expecting to update this manually, then something along these lines should work fine:

PHP Code:

<?php

  $number_of_images 
10;

  
$image_locations = array(
    
=> 'images/1.jpg',
    
=> 'images/2.jpg',
    
=> 'images/3.jpg',
    
// Etc..
    
);
  
$image_descriptions = array(
    
=> '<em>1st image</em>, this is filler text.',
    
=> '<em>2nd image</em>, this is filler text.',
    
=> '<em>3rd image</em>, this is filler text.',
    
// Etc..
    
);

  
// Gets a random number between 1 and the number of images, in this case 10.
  
$select rand(1$number_of_images);

  
$result '<td valign="top" width="10%" bgcolor="#99aa22"><p style="text-align: center;"><img src="' $image_locations[$select] . '" /><br />' $image_descriptions[$select] . '</p></td>';

  print 
$result;

  
?>
Hopefully that is quite self-explanatory. To change the images that will show up you need only add or remove values to the two arrays, and remember to keep the number_of_images variable current. This isn't the most efficient script of course. It doesn't have error-handling, and it should be counting the number of images for you. I'm not sure how much PHP you know, but maybe you could improve it to your own liking.

Also, the paragraph tag was not closed in the HTML you posted. Good luck.
Custard7A is offline   Reply With Quote