Solved

php served image as a link

Posted on 2004-08-19
2
167 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:
Squinky 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 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

16 Experts available now in Live!

Get 1:1 Help Now