?
Solved

php served image as a link

Posted on 2004-08-19
2
Medium Priority
?
188 Views
Last Modified: 2008-07-03
Hi,
I have php pulling information from an sql database and posting it for the end user.  The image is pulled with a variable and I have been trying to make the image a link also.  The link would open the source image in a new window at its un-confined size.  I have tried a few ways but keep screwing it up.  Here is the working code.
echo " <br><TABLE border = '1' cellspacing = '0' cellpadding ='0' width = '75%' align='center'>
  <TR>
    <TD rowspan=\"6\" bgcolor=\"#990033\"><div align=\"center\">";
        if (@fclose(@fopen("http://www.daltonmountain.com/used/$STKNO.JPG", "r"))) {
   
       echo "<img src=\"http://www.daltonmountain.com/used/$STKNO.JPG\" width=\"190\" height=\"142\">";
} else {
     echo "<img src=\"http://www.daltonmountain.com/used/default.jpg\">";
}

this successfully pulls the image by string $STKNO.JPG.  I would also like the image to be a link to the same in a new window.  Any Ideas?
Thanks ahead of time
Ed
0
Comment
Question by:santasvillage
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 1500 total points
ID: 11845824
How about:

echo "<a href=\"http://www.daltonmountain.com/used/$STKNO.JPG\" target="_blank" ><img src=\"http://www.daltonmountain.com/used/$STKNO.JPG\" width=\"190\" height=\"142\"></a>";
0
 
LVL 2

Expert Comment

by:b_loco
ID: 11871922
Could use this link:

<a href=\"javascript:window.open('http://www.daltonmountain.com/used/$STKNO.JPG', 'photo', 'width=190, height=142, resizable=1')\"><img src=\"http://www.daltonmountain.com/used/$STKNO.JPG\" width=\"190\" height=\"142\"></a>


and also, instead of:
@fclose(@fopen("http://www.daltonmountain.com/used/$STKNO.JPG", "r"))

you can use:

file_exists("http://www.daltonmountain.com/used/$STKNO.JPG");
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question