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,471
There are 1064 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
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
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

02-27-2005, 10:40 PM
#2
eric_bobbitt is offline eric_bobbitt
eric_bobbitt's Avatar
Status: Junior Member
Join date: Feb 2005
Location: Rockton, IL
Expertise:
Software:
 
Posts: 73
iTrader: 0 / 0%
 

eric_bobbitt is on a distinguished road

Send a message via AIM to eric_bobbitt

  Old

So what exactly do you need help with?

02-27-2005, 10:43 PM
#3
DateinaDash is offline DateinaDash
Status: The BidMaster
Join date: Nov 2004
Location: England
Expertise:
Software:
 
Posts: 10,821
iTrader: 0 / 0%
 

DateinaDash is on a distinguished road

  Old

I think it's just a case of adding the php to your existing html page.

02-27-2005, 10:44 PM
#4
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

Originally Posted by Robson
I think it's just a case of adding the php to your existing html page.
The page in the screenshot is not html its a php page.

02-27-2005, 10:48 PM
#5
DateinaDash is offline DateinaDash
Status: The BidMaster
Join date: Nov 2004
Location: England
Expertise:
Software:
 
Posts: 10,821
iTrader: 0 / 0%
 

DateinaDash is on a distinguished road

  Old

I can't see what difference that makes? Just add the script to the page and see what happens

02-27-2005, 10:51 PM
#6
FiveInteractive is offline FiveInteractive
Status: Request a custom title
Join date: Jan 2005
Location: UK
Expertise:
Software:
 
Posts: 1,216
iTrader: 0 / 0%
 

FiveInteractive is on a distinguished road

Send a message via AIM to FiveInteractive Send a message via MSN to FiveInteractive

  Old

Surely just add it as a seperate script into the page?
Place it at the bottom of your html elements and it should work fine,
Let us know

02-27-2005, 10:53 PM
#7
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

Originally Posted by TimLowe
Surely just add it as a seperate script into the page?
Place it at the bottom of your html elements and it should work fine,
Let us know

How do i do that? i know very very little about html and php.

02-27-2005, 10:54 PM
#8
FiveInteractive is offline FiveInteractive
Status: Request a custom title
Join date: Jan 2005
Location: UK
Expertise:
Software:
 
Posts: 1,216
iTrader: 0 / 0%
 

FiveInteractive is on a distinguished road

Send a message via AIM to FiveInteractive Send a message via MSN to FiveInteractive

  Old

IF you posted up the HTML soure we may be able to assist you.

02-27-2005, 10:57 PM
#9
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

here is the code of my page in the screenshot

PHP Code:
<?
require_once("conn.php");

//compose the info variables

//  "data" of the week (for exaopmle: Joke of the week)
//  can be specify by the admin and saved at the settings table
$MyWeek $aset[OfTheWeek];

$q1 "select * from dd_items where ItemID = '$MyWeek' ";
$r1 mysql_query($q1) or die(mysql_error());
$a1 mysql_fetch_array($r1);

$MyText explode("|"$a1[ItemText]);

$Of_The_Week substr($MyText[1], 0180);
$Of_The_Week .= "... <a class=TitleLinks href=\"view.php?ItemID=$a1[ItemID]\">more</a>";


//        TOP 10
$q1 "select ItemID, sum(Rating) as mr from dd_rating group by ItemID order by mr desc limit 0,9";
$r1 mysql_query($q1) or die(mysql_error());
while(
$a1 mysql_fetch_array($r1))
{
    
$q2 "select ItemTitle from dd_items where ItemID = '$a1[0]' ";
    
$r2 mysql_query($q2) or die(mysql_error());
    while(
$a2 mysql_fetch_array($r2))
    {
        
$Top_10 .= "<a class=TitleLinks href=\"view.php?ItemID=$a1[0]\">$a2[0]</a><br>\n";
    }
}

//        NEWEST
$q1 "select * from dd_items where ItemStatus = 'approved' order by DateAdded desc limit 0,9";
$r1 mysql_query($q1) or die(mysql_error());
while(
$a1 mysql_fetch_array($r1))
{
    
$Newest .= "<a class=TitleLinks href=\"view.php?ItemID=$a1[ItemID]\">$a1[ItemTitle]</a><br>\n";
}


//get the templates
require_once("templates/MainHeader.php");
require_once(
"templates/MainIndex.php");
require_once(
"templates/MainFooter.php");
?>

02-27-2005, 11:02 PM
#10
FiveInteractive is offline FiveInteractive
Status: Request a custom title
Join date: Jan 2005
Location: UK
Expertise:
Software:
 
Posts: 1,216
iTrader: 0 / 0%
 

FiveInteractive is on a distinguished road

Send a message via AIM to FiveInteractive Send a message via MSN to FiveInteractive

  Old

Okay this is a long shot, but take that php code and put it in your file, call is rss.php or something
then inbetween
require_once("templates/MainIndex.php");
and
require_once("templates/MainFooter.php");

put

require_once("templates/rss.php");

And It may work, A long shot but let me know.

Closed Thread  
Page 1 of 2 1 2 >


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

  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