RSS.class.php
class RSS
{
public function RSS()
{
// get database details from external file
require_once ('mysql_connect.php');
}
public function GetFeed()
{
return $this->getDetails() . $this->getItems();
}
private function dbConnect()
{
DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
}
private function getDetails()
{
$details = '
';
/* can add this in if needs be
*/
return $details;
}
private function getItems()
{
$itemsTable = "aw_blog";
$this->dbConnect($itemsTable);
$query = "SELECT * FROM ". $itemsTable . " WHERE store_id = 0 AND status = 1 ORDER BY post_id DESC ";
$result = mysql_db_query (DB_NAME, $query, LINK);
$items = '';
while($row = mysql_fetch_array($result))
{
$link = "http://www.quickplaysport.com/blog/" . $row['identifier'];
$attribution_link = "The article " . $row['title'] . " first appeared on Quickplaysport.com
";
$items .= '
}
$items .= '
';
return $items;
}
}
?>
[/code]
mysql_connect.php
DEFINE ('DB_USER', '*****');
DEFINE ('DB_PASSWORD', '****');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', '****');
// Make the connnection and then select the database.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );
?>
index.php
include 'add_store_codes.php';
header("Content-Type: application/xml; charset=ISO-8859-1");
include("classes/RSS.class.php");
$rss = new RSS();
echo $rss->GetFeed();
?>