random banner script open in new window? [SOLVED]

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

Post Reply
malloy
Forum Newbie
Posts: 15
Joined: Fri Jun 01, 2007 2:02 am
Location: Melbourne, Australia

random banner script open in new window? [SOLVED]

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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\"
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Standards compliance is something else to potentially worry about.
malloy
Forum Newbie
Posts: 15
Joined: Fri Jun 01, 2007 2:02 am
Location: Melbourne, Australia

Post 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 :)
Post Reply