Link to home
Start Free TrialLog in
Avatar of santasvillage
santasvillage

asked on

php served image as a link

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
ASKER CERTIFIED SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of b_loco
b_loco

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");