You just need to loop through on the query result set...
Create a function so you can reuse it like so:
<?php
function ForumsRss($dbHost, $dbUser, $dbPass, $dbName, $maxItems) {
$dbId = mysql_connect($dbHost, $dbUser, $dbPass))
if (!$dbId)
die("Could not connect to database");
if (!mysql_select_db($dbName, $dbId);
die("Could not select database");
$query = "SELECT * from Forum LIMIT 0, {$maxItems}";
$result = mysql_query($query, $dbId) or die(mysql_error());
$numRecs = mysql_num_rows($result);
header('Content-type: application/rss+xml; charset=utf-8');
echo "<?xml version=\"1.0\" ?>";
echo "<rss version=\"2.0\">
echo "<channel>";
echo "<title>North Liverpool Academy Intranet News</title>";
echo "<description>Tutorial and discussion area for Students</description>";
echo "<link>http://www.northliverpoolacademy.co.uk</link>";
// Please check this...
// Format must conform to RSS 2.0 Spec
$currentDateTime = date("D, M j G:i:s T");
if ($numRecs == 0) {
echo "<item>";
echo "<title>Empty RSS Channel List</title>";
echo "<description>There are no items</description>";
echo "<link>http://www.yoursite.com</link>";
echo "<pubDate>{$currentDateTime}</pubDate>";
echo "</item>";
}
else {
while($row = mysql_fetch_assoc($result)) {
echo "<item>";
echo "<title>{$row['Title']}</title>";
echo "<description>{$row['Post']}</description>";
echo "<link>{$row['Link']}</link>";
echo "<pubDate>{$row['TimeofPost']}</pubDate>";
echo "</item>";
}
}
echo "</channel>";
echo "</rss>";
mysql_close($dbId);
}
?>
Then you can call the function like this:
ForumsRss("localhost", "theuser", "password", "mydatabase", 3);
Cleaner? Easy to read and understand?