paulbrown Posted May 15, 2010 Share Posted May 15, 2010 First of all I would like to apologise for my ignorance. I am not much of a programmer. If you can help it will be greatly appreciated. I help to maintain a local youth choir’s web site and I decide that this year I would try to use some PHP code to help stream line the site and make it easier to maintain. Everything seems to be working fine with one exception. I am trying to use some code I found on the web to call random images each time the page is refreshed. It works fine but when I try to use an include statement in the main page and have the main code called from a separate file it won’t work. Here is the code that I am including into the main page. <?php $total = "6"; $file_type = ".jpg"; $image_folder = "rightimages"; $start = "1"; $random = mt_rand($start, $total); $image_name = $random . $file_type; echo '<img src=\"$image_folder/$image_name\" class="picB" alt=\"$image_name\" />'; ?> It does not seem to get the image but it does display the alt text where the image should be. Help! Thanks Paul Quote Link to comment Share on other sites More sharing options...
public-image Posted May 15, 2010 Share Posted May 15, 2010 try: <?php $total = "6"; $file_type = ".jpg"; $image_folder = "rightimages"; $start = "1"; $random = mt_rand($start, $total); $image_name = $random . $file_type; echo '<img src="$image_folder/$image_name" class="picB" alt="$image_name" />'; ?> 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.