robb9 |
03-24-2007 08:40 AM |
[MOD] RSS last 20 games
I realized this simple mod for RSS last 20 games:
Create a filename .php example: last20games.php
Code:
<?
$host = "host";
$root = "root";
$password ="pass";
$DataBase = "database";
mysql_connect("$host" ,"$root" ,"$password") or die("problem with database");
mysql_select_db("$DataBase") or die("problem with database");
$strsql = "SELECT * FROM games_list WHERE active=1 ORDER BY gid desc limit 20 ";
$query = mysql_query($strsql);
header("Content-type: text/xml");
//xml into the browser
//write on documents
echo "<?xml version=\"1.0\"?>
<rss version=\"2.0\">
<channel>
<title>Your Title</title>
<link>Your site</link>
<description>Feed</description>
<language>language</language>";
//cicle on items
while($row=mysql_fetch_array($query)){
$gid = $row["gid"];
$title = $row["gtitle"];
$gcount = $row["gcount"];
$gname = $row["gname"];
echo "<item>
<title>$title</title>
<link>http://www.yourserver.com/forum/arcade.php?do=play&gameid=$gid</link>
<description>
<![CDATA[
<img src=\"http://http://www.yourserver.com/forum/arcade/images/".$gname."1.gif\" align=\"right\" border=\"0\" width=\"50\" height=\"50\" vspace=\"4\" hspace=\"4\" /><br /><br />
]]>
</description>
<played>$gcount</played>
</item>";
}
echo "</channel></rss>";
?>
that's all.
enjoy.
|