Link problem ..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Link problem ..

Post by Jim_Bo »

Hi,

Hope im posting in the right area .. Im sure this is still classed as php ..

I have a link setout like so:

Code: Select all

$result_array[] = "<a href='../data.php?action=gallery&cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='1' alt='".$row[1]."'></a>";
I cant seem to incorporate the following into it:

Code: Select all

target="_blank" » onclick="imgPop(this.href, this.target); return false;"
which goes in here somewhere:

Code: Select all

"<a href='../data.php?action=gallery&cid=$cid&pid=".$row[0]." target="_blank" » onclick="imgPop(this.href, this.target); return false;"'>
?

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

remove the right angle quote as it's a binary character. If you look closely, your href attribute is surrounded by a single quote. Your added codes are trying to use double quotes, which won't break out of the single quote attribute of the href. Also, note how the double quotes require escaping.
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

re

Post by harrisonad »

Code: Select all

&quote;<a href='../data.php?action=gallery&cid=$cid&pid=&quote;.$row&#1111;0].&quote; target='_blank' onclick='imgPop(this.href, this.target); return false;'>&quote;
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

harrisonad, you're missing a single quote.
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Is this correct:

Code: Select all

$result_array[] = "<a href='../data.php?action=gallery&cid=$cid&pid=".$row[0]."' target='_blank' onclick='imgPop(this.href, this.target); return false;'><img src=".$images_dir."/tb_".$row[2]." border='1' alt=".$row[1]."></a>";
?

It opens the new window .. but no image loads within it .. The url is correct (id's) as if I chose open in new window .. it loads the pisture fine ..

Thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

try this ..

Code: Select all

$result_array[] = '<a href="../data.php?action=gallery&cid=$cid&pid='.$row[0].'" target="_blank" onclick="imgPop(this.href, this.target); return false;"><img src="'.$images_dir.'/tb_'.$row[2].'" border="1" alt="'.$row[1].'"></a>';
Your variables must escape single quotes only, and double quotes may contain variables without being escaped.
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Grr sometrhing so small causing such a hold up ..

The code posted above ... I notice when you put ya mouse over the link .. at the bottom of the browser it is displaying cid=$cid rather than cid=2 or what ever the id is ..

Also if I look at the properties of the popup window .. the address is:

../data.php?action=gallery&cid=1

I guess it should be:

../data.php?action=gallery&cid=1&pid=2

Why would it be leaving out the &pid=2 in the popup window .. But if i right click the link and open in new window .. it shows the full url and picture fine?

Thanks ..
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Code: Select all

<?
$result_array[] = "<a href=\"../data.php?action=gallery&cid=".$cid."&pid=".$row[0]."\" target=\"_blank\" onclick=\"imgPop(this.href, this.target); return false;\"><img src=\"".$images_dir."/tb_".$row[2]."\" border=\"1\" alt=\"".$row[1]."\"></a>";
?>
if that wont work see if $row[whatever] is actually returning something

And as for the $cid look At your code.
I am surprised it doesnt return &cid=$cid :)

Code: Select all

?action=gallery&amp;cid=$cid&amp;pid=&quote;.$row&#1111;0].&quote;
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

The code is fine, its only Phenom posted code that didnt return the $cid value, yours and others return it fine .. I guess it was sommin in the style of code ..

The code ol4pr0 has posted above doesnt open the picture in the new window .. I have tried it im that manner allready .. and the \" \" doesnt work .. It opens the picture in the same window not in the popup window ..

and using 'bla' seems to open the popup window but not load the image ..

Thanks
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

try that piece of code with plain html and see what happens with your
javascript function.

and try to print out the vars you are trying to pass into the javascript
this.href &.. ect..
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

I am still unable to get this to work .. using it with plain html works fine .. but trying to mix it with php I cant seem to get it to work properly .. when you click on the link .. it opens the popup window .. but nothin loads in it .. if you right click on the link and use open in new window .. it opens the link fine?

Thanks ..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what code are you using now?
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

This is the closest I have been able to get:

Code: Select all

$result_array[] = "<a href='../data.php?action=gallery&cid=$cid&pid=".$row[0]."' target='_blank' onclick='imgPop(this.href, this.target); return false;'><img src=".$images_dir."/tb_".$row[2]." border='1' alt=".$row[1]."></a>";
if I right click the popup window and view it .. the links shows as:

http://www.bla.com/data.php?action=gallery&cid=1

Also tried:

Code: Select all

$result_array[] = "<a href=\"../data.php?action=gallery&cid=$cid&pid=".$row[0]."\" target=\"_blank\" onclick=\"imgPop(this.href, this.target); return false;\"><img src=".$images_dir."/tb_".$row[2]." border=\"1\" alt=".$row[1]."></a>";
I guess it needs the pid=bla to show the image ..

Thanks ..
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

look at the html it generates. What does it output?
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Do you mean on mouse over? ... Not sure what you mean exactly ..

Thanks
Post Reply