levidyllan Posted June 11, 2007 Share Posted June 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/55071-php-rss/ Share on other sites More sharing options...
zabsmarty Posted June 11, 2007 Share Posted June 11, 2007 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); Quote Link to comment https://forums.phpfreaks.com/topic/55071-php-rss/#findComment-272287 Share on other sites More sharing options...
levidyllan Posted June 11, 2007 Author Share Posted June 11, 2007 cheers z will give this a go laters thanks Quote Link to comment https://forums.phpfreaks.com/topic/55071-php-rss/#findComment-272297 Share on other sites More sharing options...
levidyllan Posted June 11, 2007 Author Share Posted June 11, 2007 hi, how do i save this program, php, xml etc , as there are no start tags <?php etc, just looks like theres the starting section missing. si Quote Link to comment https://forums.phpfreaks.com/topic/55071-php-rss/#findComment-272334 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.