PDA

View Full Version : RSS feed in php


gigiloumill
11-28-2009, 09:18 PM
Guys, I don't know why this code will not disply the description of the link. Anybody have any suggestions? Thanks.

<?php


require_once('rss_fetch.inc');

// how many feeds?
$num_items = 5;
// RSS feed
$rss = fetch_rss( 'http://rss.cnn.com/rss/cnn_topstories.rss' );

if($rss) {
$items = array_slice($rss->items, 0, $num_items);

echo "<ul>";
foreach ($items as $item) {
$href = $item['link'];
$title = $item['title'];
$description = $item ['description'];
echo "<li><a href=\"$href\" rel=\"nofollow\">$title</a></li>";
}
echo "</ul>";
} else {
echo "<p>Feed currently updating. Please check back soon.</p>";
}
?>

gigiloumill
11-29-2009, 04:09 PM
Anybody here?///

gigiloumill
11-29-2009, 04:43 PM
O.K. guys, once again I answered my own question. But, I really still can't figure out how to open links in new window. Can anyone help please? Thanks
Here's the code:

<?php


require_once('rss_fetch.inc');

// how many feeds?
$num_items = 1;
// RSS feed
$rss = fetch_rss( 'http://feeds.portfolio.com/portfolio/businessnews' );

if($rss) {
$items = array_slice($rss->items, 0, $num_items);

echo "<ul>";

foreach ($items as $item) {

$href = $item['link'];
$title = $item['title'];
$description=$item ['description'];

echo "<li><a href=\"$href\" rel=\"_blank\">$title,</a></li>";
echo "<li><a href=\"$href\" rel=\"_blank\">$description,</a></li>";
}
echo "</ul>";
} else {
echo "<p>Feed currently updating. Please check back soon.</p>";
}
?>

gigiloumill
11-30-2009, 03:04 PM
Can someone please look at this and tell me why is not opening in another window? thanks.

<?php

require_once('rss_fetch.inc');

// how many feeds?
$num_items = 1;
// RSS feed
$rss = fetch_rss( 'http://feeds.portfolio.com/portfolio/businessnews' );
$aString = is_string((string)array()) ? true : false; // true :D
if($rss) {
$items = array_slice($rss->items, 0, $num_items);

echo "<ul>";

foreach ($items as $item) {

$href = $item['link'];
$title = $item['title'];
$description=$item ['description'];

echo "<li><a href=\"$href\" rel=\"nofollow\">$title,</a></li>";
echo "<li><a href=\"$href\" rel=\"_blank\">$description,</a></li>";

}
echo "</ul>";
} else {
echo "<p>Feed currently updating. Please check back soon.</p>";
}
?>

gigiloumill
11-30-2009, 04:43 PM
Anybody?? or did everyone forget php all of the sudden? lol

domedia
11-30-2009, 06:48 PM
PHP doesn't open browser windows, it runs on the server.
You can use target="_blank" in HTML, but it's not standards compliant..

edbr
11-30-2009, 11:39 PM
yes it looks like a html prob not php change ref for target shouldget it standard complient or no it should work else add javascript to open a window