BoarderLine Posted December 3, 2008 Share Posted December 3, 2008 Hi all, Please help. I am using the following code in the attempt to display an RSS Feed on my site that will scroll text (left to right) along the top of the page. The code works in displaying the feed however I am unsure how to get this to scroll a single line of text??? Any ideas cause im null :-( <? $MAXLINKCOUNT = 10; // (* 2) if =10, 5 news items will show $MAX_DESC_CHARS = 120; $insideitem = false; $tag = ""; $title = ""; $description = ""; $link = ""; $linkcount = 0; function startElement($parser, $name, $attrs) { global $insideitem, $tag, $title, $description, $link; if ($insideitem) { $tag = $name; } elseif ($name == "ITEM") { $insideitem = true; } } function endElement($parser, $name) { global $insideitem, $tag, $title, $description, $link, $linkcount, $MAXLINKCOUNT, $MAX_DESC_CHARS; if ($name == "ITEM" && $linkcount <= $MAXLINKCOUNT) { if (strlen($description) > $MAX_DESC_CHARS) { $description = wordwrap($description, $MAX_DESC_CHARS, "-=CUT OFF HERE=-"); $pos = strpos($description, "-=CUT OFF HERE=-"); $description = trim(substr($description, 0, $pos)) . "..."; } $description = htmlspecialchars(trim($description)); $description = str_replace(""", """, $description); printf("<dt><b><a href='%s'>%s</a></b></dt>", trim($link),htmlspecialchars(trim($title))); printf("<dt>%s</dt><br>",$description); $title = ""; $description = ""; $link = ""; $insideitem = false; } } function characterData($parser, $data) { global $insideitem, $tag, $title, $description, $link, $linkcount; if ($insideitem) { switch ($tag) { case "TITLE": $title .= $data; break; case "DESCRIPTIon": $description .= $data; break; case "LINK": $link .= $data; $linkcount++; break; } } } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); $fp = fopen("--enter url for news feed here--","r") or die("Error reading rss data."); while ($data = fread($fp, 2048)) { xml_parse($xml_parser, $data, feof($fp)); } fclose($fp); xml_parser_free($xml_parser); ?> Link to comment https://forums.phpfreaks.com/topic/135276-rss-feed-help-pls/ Share on other sites More sharing options...
s0c0 Posted December 3, 2008 Share Posted December 3, 2008 I believe you will need to use javascript for scrolling or dare I say a marquee tag. Link to comment https://forums.phpfreaks.com/topic/135276-rss-feed-help-pls/#findComment-704580 Share on other sites More sharing options...
BoarderLine Posted December 3, 2008 Author Share Posted December 3, 2008 haha thanks nice work Link to comment https://forums.phpfreaks.com/topic/135276-rss-feed-help-pls/#findComment-704591 Share on other sites More sharing options...
BoarderLine Posted December 3, 2008 Author Share Posted December 3, 2008 any ideas on how this can be used to display more than one feed? Link to comment https://forums.phpfreaks.com/topic/135276-rss-feed-help-pls/#findComment-704648 Share on other sites More sharing options...
s0c0 Posted December 4, 2008 Share Posted December 4, 2008 Really you should be using PHP 5's built in support of XML and RSS stuff. It will drastically reduce the lines of code you use plus cure any headaches and gray hair you may get from the way you are doing it now. I dug up this from back-in-the-day, its way basic, but it will give you a good starting point. php.net is your friend application: http://cnizz.com/code/php/simplexml-file-load.php code: http://cnizz.com/code/php/simplexml-file-load.phps Link to comment https://forums.phpfreaks.com/topic/135276-rss-feed-help-pls/#findComment-705683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.