Page 1 of 3
Link problem ..
Posted: Tue Mar 29, 2005 6:59 pm
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
Posted: Tue Mar 29, 2005 7:08 pm
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.
re
Posted: Tue Mar 29, 2005 7:41 pm
by harrisonad
Code: Select all
"e;<a href='../data.php?action=gallery&cid=$cid&pid="e;.$rowї0]."e; target='_blank' onclick='imgPop(this.href, this.target); return false;'>"e;
Posted: Tue Mar 29, 2005 7:44 pm
by feyd
harrisonad, you're missing a single quote.
Posted: Tue Mar 29, 2005 9:37 pm
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
Posted: Tue Mar 29, 2005 10:19 pm
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.
Posted: Tue Mar 29, 2005 10:36 pm
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 ..
Posted: Tue Mar 29, 2005 11:33 pm
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&cid=$cid&pid="e;.$rowї0]."e;
Posted: Tue Mar 29, 2005 11:47 pm
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
Posted: Tue Mar 29, 2005 11:50 pm
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..
Posted: Sun Apr 03, 2005 6:17 pm
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 ..
Posted: Sun Apr 03, 2005 6:20 pm
by feyd
what code are you using now?
Posted: Sun Apr 03, 2005 6:32 pm
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 ..
Posted: Sun Apr 03, 2005 6:37 pm
by feyd
look at the html it generates. What does it output?
Posted: Sun Apr 03, 2005 6:39 pm
by Jim_Bo
Hi,
Do you mean on mouse over? ... Not sure what you mean exactly ..
Thanks