Page 1 of 1

random banner script open in new window? [SOLVED]

Posted: Thu Sep 20, 2007 1:34 am
by malloy
Hi all,

This should be simple. I have the roatating banner script below working fine but im wanting the URL's to open in new window. I just don't know how to do it. In html it is target="_blank" but im not sure in PHP.

My code is as follows.

Code: Select all

<?php 

$ban1 = "frog.jpg" ;
$url1 = "http://www.frog.com"; 
$ban2 = "snail.jpg";
$url2 = "http://www.snail.com"; 

$randomNum = rand (1,2);
$image = ${'ban'.$randomNum};
$url= ${'url'.$randomNum};

Print "<a href=".$url." mce_href=".$url."><img src=".$image." border=0></a>";
?>
Any assistance would be greatly appreciated.

Posted: Thu Sep 20, 2007 1:36 am
by s.dot
PHP just outputs HTML. So your solution is correct. The only problem you may run into is with the quotes. So escape the " with \, so it looks like target=\"_blank\"

Posted: Thu Sep 20, 2007 9:25 am
by feyd
Standards compliance is something else to potentially worry about.

Posted: Thu Sep 20, 2007 8:21 pm
by malloy
Thanks a lot scottayy,

Your solution:

Code: Select all

Print "<a href=".$url." mce_href=".$url." target=\"_blank\" ><img src=".$image." border=0></a>";
Worked a treat.
Have a great day :)