Page 1 of 1
help with this php code please
Posted: Fri Dec 10, 2004 7:53 pm
by sung7psi
i have the following php code on my site and need the link to open in a new window...where do i add target="_blank"
not sure as to where to put it in
if ($bannerDetails['type']=="custom") {
echo "<a href=\"click.php?refid=".$bannerDetails['id']."\" target=\"new\"><img src=\"".$bannerDetails['imgpath']."\" alt=\"".$bannerDetails['alttext']."\" border=\"0\"><br>".$bannerDetails['textunder']."</a>";
// echo "<a href=\"".$bannerDetails['url']."\"><img src=\"".$bannerDetails['imgpath']."\" alt=\"".$bannerDetails['alttext']."\" border=\"0\"><br>".$bannerDetails['textunder']."</a>";
} else if ($bannerDetails['type']=="code") {
echo $bannerDetails['banner_code'];
}
}
mysql_free_result($getAdvert); ?> </td>
thanks
sung
Posted: Fri Dec 10, 2004 8:06 pm
by timvw
first ask yourself where you put the
Posted: Fri Dec 10, 2004 8:08 pm
by sung7psi
i'm a newbie to php and not quite familiar with it
Posted: Fri Dec 10, 2004 8:34 pm
by timvw
well, i see you are a newbie on this forum too... might want to read the sticky with title: posting code ... first
Posted: Fri Dec 10, 2004 8:37 pm
by sung7psi
sorry about that
Code: Select all
if ($bannerDetails['type']=="custom") {
echo "<a href="click.php?refid=".$bannerDetails['id']."" target="new"><img src="".$bannerDetails['imgpath']."" alt="".$bannerDetails['alttext']."" border="0"><br>".$bannerDetails['textunder']."</a>";
// echo "<a href="".$bannerDetails['url'].""><img src="".$bannerDetails['imgpath']."" alt="".$bannerDetails['alttext']."" border="0"><br>".$bannerDetails['textunder']."</a>";
} else if ($bannerDetails['type']=="code") {
echo $bannerDetails['banner_code'];
}
}
mysql_free_result($getAdvert); ?> </td>
Posted: Fri Dec 10, 2004 8:41 pm
by Benjamin
Change the "new" in target=\"new\ to "_blank".
Posted: Fri Dec 10, 2004 8:45 pm
by sung7psi
tried changing "new" to _blank
but it didn't work
Posted: Fri Dec 10, 2004 9:07 pm
by Benjamin
Well that code is just way too hard to read formatted like that. I rewrote parts of it, I didn't test it but the target="_blank" was in the wrong place.
Code: Select all
<?php
if ($bannerDetails['type']=="custom")
{
$data = ''
. '<a target="_blank" href="click.php?refid=' . $bannerDetails['id'] . '">'
. '<img src="' . $bannerDetails['imgpath'] . '" alt="' . $bannerDetails['alttext'] . '" border="0"><br>' . $bannerDetails['textunder'] . '</a>';
// echo "<a href="".$bannerDetails['url'].""><img src="".$bannerDetails['imgpath']."" alt="".$bannerDetails['alttext']."" border="0"><br>".$bannerDetails['textunder']."</a>";
echo $data;
}
elseif ($bannerDetails['type']=="code")
{
echo $bannerDetails['banner_code'];
}
mysql_free_result($getAdvert);
?></td>
Posted: Fri Dec 10, 2004 9:13 pm
by sung7psi
still didn't work
Posted: Fri Dec 10, 2004 9:18 pm
by Benjamin
Yes it does...
Code: Select all
<?php
$data = ''
. '<a target="_blank" href="click.php?refid=' . $bannerDetails['id'] . '">'
. '<img src="' . $bannerDetails['imgpath'] . '" alt="' . $bannerDetails['alttext'] . '" border="0"><br>' . $bannerDetails['textunder'] . '</a>';
echo $data;
?>
Tries to load an image, and when clicked, opens a new browser window.
Posted: Fri Dec 10, 2004 9:27 pm
by sung7psi
i changed the part of the code in the script and i get error messages
Posted: Fri Dec 10, 2004 9:30 pm
by Benjamin
Well post the code and the error message if you want help.