Jump to content

image display problem


paulbrown

Recommended Posts

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

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" />';

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.