Open image on a new window

All I'm trying to do is open an image on a new window. Here is my code:

print "\n<tr>";
print "<td rowspan='2'>" . "<a href='#' onclick=\'window.open
('img src=$Row[SP1],directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\' target=\"_blank\">" . "</a></td>";
print "\<\tr>";

I do not get an error but the image dose not show up.

So 2 thing I want my image to show up as a link and went the usser clicks on the link I want the image to show up on a new window.

Thanks

Rafael
rcleonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hernst42Commented:
Try this code

print "\n<tr>";
print "<td rowspan='2'>" . "<a href='#' onclick=\"window.open('" . $Row['SP1'] ."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\">" . "linkname</a></td>";
print "<tr>";
0
rcleonAuthor Commented:
Thanks,

It is almost there linkname is a small image of SP1 Now the image does not show but the name linkname does and went I click the new window opens with the large picture the small picture is SP1 and the large picture is LP1.


print "\n<tr>";
print "<td rowspan='2'>" . "<a href='#' onclick=\"window.open('" . $Row['LP1'] ."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\">" . "this should be $row['SP1']</a></td>";
print "<tr>";

Or something like that.

Thanks for you quick responce.

Rafael
0
hernst42Commented:
write this
"this should be $row['SP1']</a></td>"
as
"this should be " . $row['SP1'] ."</a></td>"

Have a look at http://de3.php.net/manual/en/language.types.string.php#language.types.string.parsing how to use quotes correctly when using variables (special arrays)
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

rcleonAuthor Commented:
OK almost

print "<td rowspan='2'>" . "<a href='#' onclick=\"window.open(' ."<img src=\"$Row[LP1]\">" . ','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\">" . "<img src=\"$Row[SP1]\" border='0'>" ."</a></td>";

I get an error
Parse error: parse error, unexpected T_STRING in /home/mendoc2/public_html/content/moreinfo.php on line 253

Thanks fir the reference

Rafael
0
Diablo84Commented:
You seen to have a little bit of confused coding there, perhaps:

print "<td rowspan='2'><a href='#' onclick=\"window.open('".$Row['LP1']."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";
0
rcleonAuthor Commented:
Almost

print "<td rowspan='2'><a href='#' onclick=\"window.open('".<img src=\"$Row['LP1']\">."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";


.$Row['LP1'] is an image also LP1 is a large image and SP1 is a small image went I click on sp1 the small image I want LP1 the large image to open on a new window.

Thanks

Rafael
0
Diablo84Commented:
i see, don't think you can do that, not directly anyway. The first parameter of the JS function window.open is the url eg:

print "<td rowspan='2'><a href='#' onclick=\"window.open('http://domain.com/page.php','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";

so you would either have to create a page for the image and load it in that or make the age dynamic and feed the image to load to it via the query string, eg:

print "<td rowspan='2'><a href='#' onclick=\"window.open('http://domain.com/page.php?img=".$Row['LP1']."','NameOfTheWindow', 'width=100,height=200,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";

Then in page.php for example you would do something like:

<img src="<?php echo $_GET['img']; ?>">

Thats a very basic example, you might need to urlencode the image name for the query string and validate the input on your page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rcleonAuthor Commented:
Thanks guys I made it work after reading the article on quotes the you guys reference about.

Thanks for all your help
0
rcleonAuthor Commented:
Guys I made it work here is the final code.

print "<td rowspan='2'><a href='#' onclick=\"window.open('".$Row['LP1']."','NameOfTheWindow', 'width=500,height=240,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');return false\"><img src=\"".$Row['SP1']."\" border='0'></a></td>";

Both of the images url are part of the MySQL database a small image apears on the page went you click on the small image a new page is loaded with the large image.

This is just what I wanted.

Once again Thanks you for all your help.

Rafael
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.