...

View Full Version : Newbie question - Coding HTML within PHP



kendalbren
03-07-2008, 05:17 AM
Hi guys.

I'm afraid it's a terribly simple problem but basically I have an RSS new feed on my site and I'd like a new window to open when the user clicks the link to the news story. Everything except the new window problem is working ok - here's the code I have:
<?php
require_once (ABSPATH . WPINC . '/rss-functions.php');

$url = 'http://www.onestopclick.com/rss/Industry-News.xml';
$rss = fetch_rss( $url );
if ( $rss ) {
echo "<p>";
$i = 1;
foreach ($rss->items as $item) {
$href = $item['link'];
$title = $item['title'];
$description = $item['description'];
echo "<a href=$href>$title</a>
<br />$description<br />";
if ($i == 2 ) break;
$i = $i + 1;
}
echo "</p>";
}
?>

I know I need to use target="_blank" somewhere but I don't know where to put it.

Thanks in advance.

Inigoesdr
03-07-2008, 05:27 AM
Change

echo "<a href=$href>$title</a>
to

echo "<a href=\"$href\" target=\"_blank\">$title</a>

rangana
03-07-2008, 05:28 AM
I'm not fluent in PHP, but maybe adding target="_blank" in the <a> tag might help.


echo "<a href=\"$href\" target=\"_blank\">$title</a>
<br />$description<br />";


See if it helps :D

kendalbren
03-07-2008, 05:36 AM
Thanks a lot guys. Super fast response too!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum