rss xml generator via php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blade_922
Forum Contributor
Posts: 132
Joined: Wed Jul 12, 2006 4:57 pm

rss xml generator via php

Post by blade_922 »

hey ok. im having loads of toruble here, i cant find one damn tutorial anywhere to show me how to make an rss feed. I also need it to show html formating like images etc in the images. I know this is possible coz ive seen it on loads of sites. I tried making one myself but have no idea what to do lol. I tried this below in xml file

Code: Select all

<?php 
// Let us first make sure the php file is 
// interpeted as xml information 

echo '<?xml version="1.0" encoding="ISO-8859-1" ?>'; 


// SQL connection 
$query = "SELECT * FROM mos_content ORDER BY (id) DESC"; 
$res = mysql_query($query); 
$num = mysql_num_rows($res); 
if($num == 0) 
{ 
  exit; 
} 
else 
{ 
  // First we print the overall xml information 
 
// First we print the overall xml information 
  echo "<rss version=\"2.0\">\n"; 
  echo "<channel>\n"; 
  // Here comes the global title for you rss 
  echo "<title>My newsfeed</title>\n"; 
  // Here comes the url for the page that the rss applies for 
  echo "<link>http://www.pspcave.com/</link>\n"; 
  // Here comes a short description of the page 
  echo "<description>BzaBlog Newsfeed</description>\n"; 
   
  // Now over to the dynamic part 
   
  while($sql = mysql_fetch_object($res)) 
  { 
    $blog_title       = stripslashes($sql->title); 
    $blog_link        = "blog.php?ID=".$sql->id; 
    $blog_description = stripslashes($sql->introtext); 
    echo "<item>\n"; 
    echo "<title>".$blog_title."</title>\n"; 
    echo "<link>".$blog_link."</link>\n"; 
    echo "<description>\n"; 
    echo $blog_description; 
    echo "</description>\n"; 
    echo "</item>\n"; 
  } 
   
  // And at last the closing tags for the overall info 
  echo "</channel>\n"; 
  echo "</rss>\n"; 
} 
?>

dont laugh at me if i done it totally wrong etc. :(
blade_922
Forum Contributor
Posts: 132
Joined: Wed Jul 12, 2006 4:57 pm

Post by blade_922 »

i was hoping for help on this by today :(
Post Reply