| | |
Help for Newbie! Need to create a link to larger image target _blank in PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 4
Reputation:
Solved Threads: 0
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)
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)
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>";
Last edited by peter_budo; Sep 18th, 2008 at 12:58 pm. Reason: Keep It Organized - please use [code] tags
Could you not put the link in the array like:
or am I misunderstanding the question?
PHP Syntax (Toggle Plain Text)
<?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?
Last edited by Banderson; Sep 18th, 2008 at 1:41 pm. Reason: Inserted target=blank
And if you're interested in making that code a little smaller:
php Syntax (Toggle Plain Text)
<?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>"; ?>
Last edited by MVied; Sep 18th, 2008 at 4:07 pm.
"We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." - Robert Wilensky
•
•
Join Date: Sep 2008
Posts: 4
Reputation:
Solved Threads: 0
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!
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
php Syntax (Toggle Plain Text)
"<a href=\"re_images/".$img."\" target=\"_blank\"><img src=\"re_images/".$img."\" alt=\"ALT TEXT\"width=\"100\" height=\"100\" border=\"1\" /></a><br />\n";
"We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." - Robert Wilensky
![]() |
Other Threads in the PHP Forum
- Previous Thread: Returning values from PHP file
- Next Thread: how to assign javascript variable to php variable
Views: 726 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web webdesign xml youtube





