Jump to content

PHP rss


levidyllan

Recommended Posts

hey peps!

 

has anyone got a link to an easy RSS page/xml tut.  I used a aspx code the other day and was wondering if there is a PHP equivalent.

 

Basically the page basically when loaded connected to a db, and colleted the top ten records, then created a xml page from this data etc so it showed as a rss feed straight away.

 

thanks si

Link to comment
https://forums.phpfreaks.com/topic/55071-php-rss/
Share on other sites

Hello;

how r u ...

for PHP rss

u mean to say when u click rss link it redirect to xml page for this i send u example try it and that will b helpful for u *******

 

$article_category_id=$_GET['article'];

 

$result_article_cat = mysql_query("select * from ms_article_category where article_cat_id=$article_category_id", $link);

if (!$result_article_cat) {

  echo("<p>Error performing query: " . mysql_error() . "</p>");

  exit();

}

$row_article_cat = mysql_fetch_array($result_article_cat, MYSQL_ASSOC);

 

$article_cat_name=$row_article_cat['article_name'];

$article_name = str_replace(" ","_",$article_cat_name);

 

 

$xml='<?xml version="1.0" ?'.'>  <rss version="2.0"> <channel>

  <title>'. $row_article_cat['article_name'].'</title>

  <link>http://www.puaclub.net</link>

  <description>New articles from puaclub</description>

  <language>en-us</language> ';

 

 

 

$result_article = mysql_query("select * from ms_articles where article_cat_id=$article_category_id", $link);

if (!$result_article) {

  echo("<p>Error performing query: " . mysql_error() . "</p>");

  exit();

}  ?>

 

<?

while($row_article = mysql_fetch_array($result_article, MYSQL_ASSOC)) {

 

 

 

$xml=$xml.' <item>

  <title> '. $row_article['article_title'].'</title>

  <link>http://www.puaclub.net/demo/articlereview.php?articleid='.$row_article['article_id'].'</link>

  <image>http://www.puaclub.net/demo/'. $row_article['Images'] .'"</image>

  <description>'. $row_article['article_des'] .'</description>

  <pubDate>'.$row_article['date'].' </pubDate>

  </item>';

 

}

 

$xml = $xml.'</channel>

  </rss>';

 

$myFile =$article_name.'.xml';

$fh = fopen($myFile, 'w') or die("can't open file");

$stringData = $xml;

fwrite($fh, $stringData);

fclose($fh);

 

header('location:'.$myFile);

Link to comment
https://forums.phpfreaks.com/topic/55071-php-rss/#findComment-272287
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.