Solved

php served image as a link

Posted on 2004-08-19
2
170 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
2 Comments
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

937 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now