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 Link to comment https://forums.phpfreaks.com/topic/201903-image-display-problem/ 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" />'; ?> Link to comment https://forums.phpfreaks.com/topic/201903-image-display-problem/#findComment-1058949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.