Ad block is installed and active. Please support us by disabling it.
HomeSaturday, January 20, 2018, 16:40:28
1

MySQL to RSS

Tuesday, February 10, 15, 00:36:07, 3 Yaers Ago Via wain, Hits: 3294
Publishing MySQL data in RSS
config.php

Code:
<?php
$dbhost = 'localhost';
$dbusername = 'root';
$dbpassword = 'mydbpass';
$dbname = 'test';
$conn=mysql_connect($dbhost, $dbusername, $dbpassword);
if(!$conn) :
die('Could not connect: ' . mysql_error());
endif;
$db=mysql_select_db($dbname, $conn);
if(!$db) :
die (mysql_error());
endif;
?>


rss.php

Code:
<?php header('Content-type: application/rss+xml'); ?>
<?php echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>example.com</title>
<description>news example.com</description>
<link>http://example.com</link>
<?php
include ('config.php');
$res = mysql_query("SELECT id, title, description, date
FROM news ORDER by date DESC LIMIT 5")
or die(mysql_error());
while($row = mysql_fetch_array($res)){
?>
<item>
<title> <?php echo $row['title']; ?></title>
<description> <?php echo htmlspecialchars($row['description'], ENT_QUOTES); ?> </description>
<link>http://example.com/?id=<?php echo $row['id']; ?></link>
<guid>http://example.com/<?php echo $row['id']; ?>.html</guid>
<pubDate> <?php echo date("r", strtotime($row["date"])); ?></pubDate>
</item>
<?php
}
?>

Sign In

Sponsor

Related

Contact Us 2.0. with HTML Page and Pop Up Frame

This is the same Contact Us 2.0. that is in this forum, But I have added more options to this script and a html page with a very nice pop Up frame that DONT get block by any pop Up software. Many websites use this type of script to bypass the blocking…

Creating a CAPTCHA with PHP with imagecreate

This tutorial will show you how to create a form with Captcha, Requirement(s): PHP Server, GD Graphics Library

PHP Jquery Form

PHP Jquery Form allow your visitors to contact you directly from your website.

Prevent the error loading XML – libxml_use_internal_errors

libxml_use_internal_errors() allows you to disable standard libxml errors and enable user error handling.

PHP $_POST Function

Collect values from a form sent with method post

ShoutBox 1.1. PHP Script

ShoutBox allows your users to post short messages on your site. The script is lightweight and very easy to install and use.

PHP File Create

Create and write data to a file using the php frwite function.

Link Base Pro :: Free Link Index Script

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links.

Creating a Math CAPTCHA with PHP - PHP Tutorial

This tutorial will show you how to create a form with Math Captcha.

PHP $_GET Function

Get function in PHP
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.