Solved

php served image as a link

Posted on 2004-08-19
2
176 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

839 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