crepiuza Posted October 13, 2010 Share Posted October 13, 2010 Hello everybody , i echo into a marquee one variable which is having value (item) of a rss feed which am parsing . The problem is that into the marquee, is echoed finally, just the first item and not all the items of the feed ! So when am parsing a News rss feed, which is having par example 5 news, my marquee is showing just the first of those 5 Why is this happening ? Here is the code i use : The marquee <marquee behavior="scroll" scrollamount="5"><b><?php echo "<a href=$sigma2>$sealakefa</a></b></marquee> The php/rss part function readRSSFile($filename) { $data = implode('', file($filename)); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $values, $tags); xml_parser_free($parser); foreach ($tags as $key => $val) { if ($key == 'item') { $itemRanges = $val; for($i=0; $i<count($itemRanges); $i+=2) { $offset = $itemRanges[$i] + 1; $len = $itemRanges[$i + 1] - $offset; $result[] = combineItem(array_slice($values, $offset, $len)); } } } return $result; } function combineItem($itemValues) { for ($i=0; $i<count($itemValues); $i++) { if(isset($itemValues[$i]['value'])) { $item[$itemValues[$i]['tag']] = $itemValues[$i]['value']; } } return $item; } $latest = readRSSFile("http://www.jamaicaobserver.com/rss/news/"); for($i=0; $i<count($latest); $i++) { $sigma = $latest[$i]['link']; $tauvf = $latest[$i]['title']; } I want all the items of the feed to be shown into my marquee ! How to do that can you help me please ..? What's wrong ? Thanks in advance.. Link to comment https://forums.phpfreaks.com/topic/215808-php-rss-and-marquee-problem/ Share on other sites More sharing options...
phpeter Posted October 13, 2010 Share Posted October 13, 2010 Not sure if this will show the result you want, but it should work: <?php function readRSSFile($filename) { $xml = new SimpleXMLElement(file_get_contents($filename)); return $xml->channel; } $latest = readRSSFile("http://www.jamaicaobserver.com/rss/news/"); foreach($latest->item as $latest) { $sigma = $latest->link; $tauvf = $latest->title; ?> <marquee behavior="scroll" scrollamount="5"><b><a href="<?php echo $sigma; ?>"><?php echo $tauvf; ?></a></b></marquee> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/215808-php-rss-and-marquee-problem/#findComment-1121955 Share on other sites More sharing options...
crepiuza Posted October 13, 2010 Author Share Posted October 13, 2010 Oh thank you very much phpeter, that works ! Just i face a litle trouble now, cause, the marquee is horizontial and the news that we fecth are shown in the page vertical ! Each one downside of the other, in this way : news no1 news no2 news no3 news no4 news no5 but i want these news to be shown horizontially and not as now vertical, like this : news no1 news no2 ... ...news no5 How to fix that ..? Link to comment https://forums.phpfreaks.com/topic/215808-php-rss-and-marquee-problem/#findComment-1121965 Share on other sites More sharing options...
phpeter Posted October 13, 2010 Share Posted October 13, 2010 doh! I should have caught that before I posted. It's repeating marquees instead of putting all of the links into one. This should fix it: <marquee behavior="scroll" scrollamount="5"> <?php function readRSSFile($filename) { $xml = new SimpleXMLElement(file_get_contents($filename)); return $xml->channel; } $latest = readRSSFile("http://www.jamaicaobserver.com/rss/news/"); foreach($latest->item as $latest) { $sigma = $latest->link; $tauvf = $latest->title; ?> <b><a href="<?php echo $sigma; ?>"><?php echo $tauvf; ?></a></b> <?php } ?> </marquee> Link to comment https://forums.phpfreaks.com/topic/215808-php-rss-and-marquee-problem/#findComment-1121983 Share on other sites More sharing options...
crepiuza Posted October 14, 2010 Author Share Posted October 14, 2010 So we had to include the php part into the marquee amazing.. so simple Really thank you so much phpeter !!! [ SOLVED ] Link to comment https://forums.phpfreaks.com/topic/215808-php-rss-and-marquee-problem/#findComment-1121991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.