Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1950 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Adding new php to old php

Thread title: Adding new php to old php
     
    Thread tools Search this thread Display Modes  
Prev Previous Post   Next Post Next
02-27-2005, 10:37 PM
#1
TheWebJunkie is offline TheWebJunkie
Status: Sin Binner
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 129
iTrader: 0 / 0%
 

TheWebJunkie is on a distinguished road

  Old  Adding new php to old php

Hello guys i need to add a rss news feed to my current php script



here is the code for the rss news feed

PHP Code:
<?php
$insideitem 
false;
$tag "";
$title "";
$description "";
$link "";
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;
 if (
$name == "ITEM") {
  
printf("<dt><b><a href='%s'>%s</a></b></dt>",
  
trim($link),htmlspecialchars(trim($title)));
  
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
  
$title "";
  
$description "";
  
$link "";
  
$insideitem false;
 }
}
function 
characterData($parser$data) {
 global 
$insideitem$tag$title$description$link;
 if (
$insideitem) {
 switch (
$tag) {
  case 
"TITLE":
  
$title .= $data;
  break;
  case 
"DESCRIPTION":
  
$description .= $data;
  break;
  case 
"LINK":
  
$link .= $data;
  break;
 }
 }
}
$xml_parser xml_parser_create();
xml_set_element_handler($xml_parser"startElement""endElement");
xml_set_character_data_handler($xml_parser"characterData");
$fp fopen("http://www.just-food.com/affiliates/news_rss.asp","r")
 or die(
"Error reading RSS data.");
while (
$data fread($fp4096))
 
xml_parse($xml_parser$datafeof($fp))
  or die(
sprintf("XML error: %s at line %d",
   
xml_error_string(xml_get_error_code($xml_parser)),  
   
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>
Could someone help me out

     


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed