Hi
I have a site that I am struggling to get it to do what I need it to! I have managed to add how many photos appear but I cannot add A HREF links around these thumbnails to get a larger picture to appear in browser window. Code is below - all help appreciated. ( I want the 100X100 images to be clickable and show full size in another window)

if(!empty($a1[image]))
	{
		$im_array = explode("|", $a1[image]);

		$FirstImage = "<img src=\"re_images/$im_array[0]\" width=100 height=100 border=1>";
		
		$SecondImage = "<img src=\"re_images/$im_array[1]\" width=100 height=100 border=1>";

		$ThirdImage = "<img src=\"re_images/$im_array[2]\" width=100 height=100 border=1>";

		$FourthImage = "<img src=\"re_images/$im_array[3]\" width=100 height=100 border=1>";
		
		$FifthImage = "<img src=\"re_images/$im_array[4]\" width=100 height=100 border=1>";
		
		$SixthImage = "<img src=\"re_images/$im_array[5]\" width=100 height=100 border=1>";
		
	}


	$ShowInfo .= "</td>\n\t<td align=center valign=top>$FirstImage<br>$SecondImage<br>$ThirdImage<br>$FourthImage<br>$FifthImage<br>$SixthImage<br>For more information call<br><b> $a1[FirstName] $a1[LastName]<br>$a1[phone]</b><br>or click <a class=RedLink href=\"email.php?AgentID=$a1[AgentID]&ListingID=$a1[ListingID]\">here</a> to email.<center>";
	
	
	$ShowInfo .= "</center></td>\n</tr>";

Recommended Answers

All 6 Replies

Could you not put the link in the array like:

<?php
if(!empty($a1[image]))
	{
		$im_array = explode("|", $a1[image]);

		$FirstImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[0]\" width=100 height=100 border=1></a>";
		
		$SecondImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[1]\" width=100 height=100 border=1></a>";

		$ThirdImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[2]\" width=100 height=100 border=1></a>";

		$FourthImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[3]\" width=100 height=100 border=1></a>";
		
		$FifthImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[4]\" width=100 height=100 border=1></a>";
		
		$SixthImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[5]\" width=100 height=100 border=1></a>";
		
	}


	$ShowInfo .= "</td>\n\t<td align=center valign=top>$FirstImage<br>$SecondImage<br>$ThirdImage<br>$FourthImage<br>$FifthImage<br>$SixthImage<br>For more information call<br><b> $a1[FirstName] $a1[LastName]<br>$a1[phone]</b><br>or click <a class=RedLink href=\"email.php?AgentID=$a1[AgentID]&ListingID=$a1[ListingID]\">here</a> to email.<center>";
	
	
	$ShowInfo .= "</center></td>\n</tr>";
?>

or am I misunderstanding the question?

And if you're interested in making that code a little smaller:

<?php
 if(!empty($a1[image])) {
  $im_array = explode("|", $a1[image]);
  $images = "";
 
  if ($im_array !== false) {
   foreach ($im_array as $img) {
    $images .= "<a href=\"re_images/".$img."\" target=\"_blank\"><img src=\"re_images/".$img."\" width=\"100\" height=\"100\" border=\"1\" /></a><br />\n";
   }
  }
 }

 $ShowInfo .= "</td>\n\t<td align=center valign=top>".$images."For more information call<br><b> ".$a1['FirstName']." ".$a1['LastName']."<br>".$a1'[phone']."</b><br>or click <a class=RedLink href=\"email.php?AgentID=".$a1['AgentID']."&ListingID=".$a1['ListingID']."\">here</a> to email.<center>";
 $ShowInfo .= "</center></td>\n</tr>";
?>

Hi
Thanks for your response. I tried that solution but I could not reference the image correctly. As they are being labelled as Image1 and so on in that line of code no matter what I tried to put in the area you labelled "link_to_your_image\" I could not get it to work and the page blanks out.

Thanks again - it's probably me being dumb and missing something obvious!

Hi
I have now cracked it thansk to your answer! I had the syntax wrong.

Following the way you have entered the link I tried entering alt text for the link but it just does not appear? Any ideas?
THanks

Hi
I have now cracked it thansk to your answer! I had the syntax wrong.

Following the way you have entered the link I tried entering alt text for the link but it just does not appear? Any ideas?
THanks

Should be something like this:

"<a href=\"re_images/".$img."\" target=\"_blank\"><img src=\"re_images/".$img."\" alt=\"ALT TEXT\"width=\"100\" height=\"100\" border=\"1\" /></a><br />\n";

Thanks for all your help - much appreciated
Regards
Alan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.