943,733 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 974
  • PHP RSS
Sep 18th, 2008
0

Help for Newbie! Need to create a link to larger image target _blank in PHP

Expand Post »
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)

php Syntax (Toggle Plain Text)
  1. if(!empty($a1[image]))
  2. {
  3. $im_array = explode("|", $a1[image]);
  4.  
  5. $FirstImage = "<img src=\"re_images/$im_array[0]\" width=100 height=100 border=1>";
  6.  
  7. $SecondImage = "<img src=\"re_images/$im_array[1]\" width=100 height=100 border=1>";
  8.  
  9. $ThirdImage = "<img src=\"re_images/$im_array[2]\" width=100 height=100 border=1>";
  10.  
  11. $FourthImage = "<img src=\"re_images/$im_array[3]\" width=100 height=100 border=1>";
  12.  
  13. $FifthImage = "<img src=\"re_images/$im_array[4]\" width=100 height=100 border=1>";
  14.  
  15. $SixthImage = "<img src=\"re_images/$im_array[5]\" width=100 height=100 border=1>";
  16.  
  17. }
  18.  
  19.  
  20. $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>";
  21.  
  22.  
  23. $ShowInfo .= "</center></td>\n</tr>";
Last edited by peter_budo; Sep 18th, 2008 at 12:58 pm. Reason: Keep It Organized - please use [code] tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AlanW is offline Offline
4 posts
since Sep 2008
Sep 18th, 2008
0

Re: Help for Newbie! Need to create a link to larger image target _blank in PHP

Could you not put the link in the array like:

PHP Syntax (Toggle Plain Text)
  1.  
  2. <?php
  3. if(!empty($a1[image]))
  4. {
  5. $im_array = explode("|", $a1[image]);
  6.  
  7. $FirstImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[0]\" width=100 height=100 border=1></a>";
  8.  
  9. $SecondImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[1]\" width=100 height=100 border=1></a>";
  10.  
  11. $ThirdImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[2]\" width=100 height=100 border=1></a>";
  12.  
  13. $FourthImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[3]\" width=100 height=100 border=1></a>";
  14.  
  15. $FifthImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[4]\" width=100 height=100 border=1></a>";
  16.  
  17. $SixthImage = "<a href=\"link_to_your_image\" target=\"_blank\"><img src=\"re_images/$im_array[5]\" width=100 height=100 border=1></a>";
  18.  
  19. }
  20.  
  21.  
  22. $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>";
  23.  
  24.  
  25. $ShowInfo .= "</center></td>\n</tr>";
  26. ?>

or am I misunderstanding the question?
Last edited by Banderson; Sep 18th, 2008 at 1:41 pm. Reason: Inserted target=blank
Reputation Points: 17
Solved Threads: 8
Junior Poster in Training
Banderson is offline Offline
66 posts
since Aug 2004
Sep 18th, 2008
0

Re: Help for Newbie! Need to create a link to larger image target _blank in PHP

And if you're interested in making that code a little smaller:
php Syntax (Toggle Plain Text)
  1. <?php
  2. if(!empty($a1[image])) {
  3. $im_array = explode("|", $a1[image]);
  4. $images = "";
  5.  
  6. if ($im_array !== false) {
  7. foreach ($im_array as $img) {
  8. $images .= "<a href=\"re_images/".$img."\" target=\"_blank\"><img src=\"re_images/".$img."\" width=\"100\" height=\"100\" border=\"1\" /></a><br />\n";
  9. }
  10. }
  11. }
  12.  
  13. $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>";
  14. $ShowInfo .= "</center></td>\n</tr>";
  15. ?>
Last edited by MVied; Sep 18th, 2008 at 4:07 pm.
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008
Sep 19th, 2008
0

Re: Help for Newbie! Need to create a link to larger image target _blank in PHP

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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AlanW is offline Offline
4 posts
since Sep 2008
Sep 19th, 2008
0

Re: Help for Newbie! Need to create a link to larger image target _blank in PHP

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AlanW is offline Offline
4 posts
since Sep 2008
Sep 19th, 2008
0

Re: Help for Newbie! Need to create a link to larger image target _blank in PHP

Click to Expand / Collapse  Quote originally posted by AlanW ...
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:
php Syntax (Toggle Plain Text)
  1. "<a href=\"re_images/".$img."\" target=\"_blank\"><img src=\"re_images/".$img."\" alt=\"ALT TEXT\"width=\"100\" height=\"100\" border=\"1\" /></a><br />\n";
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008
Sep 19th, 2008
0

Re: Help for Newbie! Need to create a link to larger image target _blank in PHP

Thanks for all your help - much appreciated
Regards
Alan
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AlanW is offline Offline
4 posts
since Sep 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Returning values from PHP file
Next Thread in PHP Forum Timeline: how to assign javascript variable to php variable





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC