iconicCreator Posted June 3, 2009 Share Posted June 3, 2009 With help, I have created a script that output/display a different image everyday. The problem is I would like to individual CSS styling to each image independently. I could add a CSS class to the out put bein echoed but the will apply to any image being display. Here is the complete code. <?php $aPictureOfTheDay = array( #Sunday array( 'img' => '/images/image.jpg', 'txt' => 'Today is Sunday.' ), #Monday array( 'img' => '/images/image.jpg', 'txt' => 'Today is Monday.' ), #Tuesday array( 'img' => '/images/image.jpg', 'txt' => 'Today is Tuesday.' ), #Wednesday array( 'img' => '/images/image.jpg', 'txt' => 'Today is Wednesday.' ) ) ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <div id="siteHeader"> <!-- Image of the day --> <img src="<?php echo $aPictureOfTheDay[date('w')]['img']; ?>" /> </div> <div id="siteFooter"> <!-- Message of the day --> <p><?php echo $aPictureOfTheDay[date('w')]['txt']; ?></p> </div> </body> </html> I have tried many methods but no luck. Can you echo each image independently, in order to apply individual styling? Thanks everyone. IC Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted June 3, 2009 Share Posted June 3, 2009 Surely all you need to do is add a class item to your $aPictureOfTheDay array (like you have already done with the 'img' and 'txt' items). Now change this line <img src="<?php echo $aPictureOfTheDay[date('w')]['img']; ?>" /> To <img src="<?php echo $aPictureOfTheDay[date('w')]['img']; ?>" class="<?php echo $aPictureOfTheDay[date('w')]['class']; ?>" /> Or wherever you want your class to be applied to. Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted June 3, 2009 Author Share Posted June 3, 2009 Surely all you need to do is add a class item to your $aPictureOfTheDay array (like you have already done with the 'img' and 'txt' items). Now change this line <img src="<?php echo $aPictureOfTheDay[date('w')]['img']; ?>" /> To <img src="<?php echo $aPictureOfTheDay[date('w')]['img']; ?>" class="<?php echo $aPictureOfTheDay[date('w')]['class']; ?>" /> Or wherever you want your class to be applied to. Thanks very much - so where do I applied the CSS styling to? I'm assuming the example above is to echo each image individually? IC Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted June 3, 2009 Share Posted June 3, 2009 I'm assuming the example above is to echo each image individually? What do you mean by this? Are you now wanting to display all images within your array regardless of the day? so where do I applied the CSS styling to? Shouldn't you know that? I dont know what you're wanting to apply your styles I was just giving an example. Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted June 3, 2009 Author Share Posted June 3, 2009 What do you mean by this? Are you now wanting to display all images within your array regardless of the day? No. My question was applying CSS styling to individual images in the array. Since the array contains a collection of images being echo one at a time each day, I was asking how do I apply CSS to the images. Lets assumed I want Monday image to have a red border and tuesday image to have a green border. All I'm trying to do is apply individual style to the images. I did the following before posting my original question. <img src="<?php echo $aPictureOfTheDay[date('w')]['img']; ?>" class="cssHere" /> The problem is - this applied the same styling to all of the images when they are echo on a given day. Anyway, sorry for any confusion and thanks for your help. IC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.