BLOG DESIGN SOLUTIONS blog). More information on the (Kids web site)

BLOG DESIGN SOLUTIONS blog). More information on the RSS 2.0 syntax can be found at feedvalidator. org/docs/rss2.html. // pull blogs from database $sql = “SELECT post_id, title, summary, . DATE_FORMAT(postdate, ‘%a, %d %b %Y %T GMT’) as pubdate . FROM posts ORDER BY postdate DESC LIMIT 10″; $result = mysql_query($sql); The script now performs the familiar SELECT query in which it grabs the latest ten blog post titles and summaries. The postdate is formatted in a special way for RSS feeds and includes the time zone (in this case, GMT), which you may have to change according to where your live website is hosted. if ($mypost = mysql_fetch_array($result)) { do { $post_id = $mypost[”post_id”]; $pubdate = $mypost[”pubdate”]; $summary = format($mypost[”summary”]); $title = $mypost[”title”]; $title = strip_tags($title); $title = htmlentities($title); $rssfile .= ” \n”; $rssfile .= ”
$pubdate\n”; $rssfile .= ” \n”; $rssfile .= ”
http://your-domain-name.com/ . post.php?post_id=$post_id\n”; $rssfile .= ” \n”; $rssfile .= ”
\n”; } while ($mypost = mysql_fetch_array($result)); } This code should again look familiar as the script loops through the posts and writes them to the $rssfile variable. Because you are writing RSS instead of HTML, the mark-up will look different, but it is still structured in a similar manner. $rssfile .=” “; Here, the final closing tags are added to the RSS feed. It is now ready for writing to your index.xml file. // write to file $fw = @fwrite($fh, $rssfile); if (!$fw) { $message = “Could not write to the file $filename”; } else {

Leave a Reply