|
|
|
|
Thread title: Adding new php to old php |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
02-27-2005, 10:37 PM
|
#1
|
Status: Sin Binner
Join date: Feb 2005
Location:
Expertise:
Software:
Posts: 129
|
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($fp, 4096))
xml_parse($xml_parser, $data, feof($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
|
Status: Junior Member
Join date: Feb 2005
Location: Rockton, IL
Expertise:
Software:
Posts: 73
|
So what exactly do you need help with?
|
|
02-27-2005, 10:43 PM
|
#3
|
Status: The BidMaster
Join date: Nov 2004
Location: England
Expertise:
Software:
Posts: 10,821
|
I think it's just a case of adding the php to your existing html page.
|
|
02-27-2005, 10:44 PM
|
#4
|
Status: Sin Binner
Join date: Feb 2005
Location:
Expertise:
Software:
Posts: 129
|
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
|
Status: The BidMaster
Join date: Nov 2004
Location: England
Expertise:
Software:
Posts: 10,821
|
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
|
Status: Request a custom title
Join date: Jan 2005
Location: UK
Expertise:
Software:
Posts: 1,216
|
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
|
Status: Sin Binner
Join date: Feb 2005
Location:
Expertise:
Software:
Posts: 129
|
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
|
Status: Request a custom title
Join date: Jan 2005
Location: UK
Expertise:
Software:
Posts: 1,216
|
IF you posted up the HTML soure we may be able to assist you.
|
|
02-27-2005, 10:57 PM
|
#9
|
Status: Sin Binner
Join date: Feb 2005
Location:
Expertise:
Software:
Posts: 129
|
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], 0, 180);
$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
|
Status: Request a custom title
Join date: Jan 2005
Location: UK
Expertise:
Software:
Posts: 1,216
|
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.
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|