Hey Rodolfo,
I got most of the RSS feed information pulled from my SQL table. I am however stuck on getting the image link since I am not familiar with G and the image page link is not in the database. Can you please help with the image link that gives a link to the image page? Thanks.
RSS.class.php
rss.php
I got most of the RSS feed information pulled from my SQL table. I am however stuck on getting the image link since I am not familiar with G and the image page link is not in the database. Can you please help with the image link that gives a link to the image page? Thanks.
RSS.class.php
PHP:
<?php
class RSS
{
public function RSS()
{
DEFINE ('SITE_TITLE', 'Cheverto');
DEFINE ('SITE_DESCRIPTION', 'Cheverto Hosting Script');
DEFINE ('SITE_URL', 'http://www.cheverto.com');
}
public function GetFeed()
{
return $this->getItems();
}
private function dbConnect()
{
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'cheverto');
DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD));
}
private function getItems()
{
$items = '';
$items .= '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<description>'. SITE_DESCRIPTION. '</description>
<title>'. SITE_TITLE. '</title>
<link>'. SITE_URL .'/explore/</link>';
$itemsTable = "chv_images";
$this->dbConnect($itemsTable);
$query = "SELECT * FROM chv_images ORDER BY image_id DESC LIMIT 50";
mysql_query("SET NAMES 'utf8'", LINK);
$result = mysql_db_query (DB_NAME, $query, LINK);
while($row = mysql_fetch_array($result))
{
$d = $row["image_date_gmt"];
$items .= '
<item>
<title>'. $row["image_description"] .'</title>
<description>
<img src="'. SITE_URL .'/images/'. $row["image_name"] .'.md.'. $row["image_extension"] .'"/>
</description>
<pubDate>'. gmdate(DATE_RSS, strtotime($d)) .'</pubDate>
<link></link>
<guid></guid>
</item>';
}
$items .= '</channel>
</rss>';
return $items;
}
}
?>
rss.php
PHP:
<?php
header("Content-Type: application/xml; charset=UTF-8");
include("RSS.class.php");
$rss = new RSS();
echo $rss->GetFeed();
?>
Last edited: