BMS-HOSxP Community

HOSxP => Development => ข้อความที่เริ่มโดย: doramon ที่ กรกฎาคม 17, 2010, 11:05:30 AM

หัวข้อ: Creating a Custom RSS Feed with PHP and MySQL
เริ่มหัวข้อโดย: doramon ที่ กรกฎาคม 17, 2010, 11:05:30 AM
http://www.webreference.com/authoring/languages/xml/rss/custom_feeds/
หัวข้อ: Re: Creating a Custom RSS Feed with PHP and MySQL
เริ่มหัวข้อโดย: doramon ที่ กรกฎาคม 17, 2010, 11:12:45 AM
http://www.ajaxray.com/blog/2008/03/08/php-universal-feed-generator-supports-rss-10-rss-20-and-atom/
หัวข้อ: Re: Creating a Custom RSS Feed with PHP and MySQL
เริ่มหัวข้อโดย: doramon ที่ กรกฎาคม 17, 2010, 11:14:20 AM
Code (PHP)
view sourceprint?
01.
<?
02.
error_reporting(E_ALL ^ E_NOTICE);
03.
$dbhost = "localhost";          // Database server
04.
$dbname = "sonic";      // ชื่อฐานข้อมูล
05.
$dbuser = "root"; 
06.
$dbpass = "admin";
07.
 
08.
mysql_connect($dbserver, $dbuser, $dbpass) or  die("เชื่อมต่อฐานข้อมูลไม่ได้");
09.
mysql_query("set NAMES utf8 ");
10.
 
11.
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้"); // เลือกฐานข้อมูล
12.
 
13.
 
14.
$sql = "SELECT title,description,link,pubdate FROM feed  where category like '10' and flag ='1' ORDER BY pubdate  desc limit 30";
15.
$query = mysql_db_query($dbname, $sql); // 1 อ่านหมายเหตุของบรรทัดนี้ด้านล่าง
16.
 
17.
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
18.
echo '<rss version="2.0">'."\n";
19.
echo '<channel>'."\n";
20.
 
21.
echo '<title>ข่าวทุนการศึกษา</title>'."\n";
22.
echo '<description>รวมข่าวทุนการศึกษา</description>'."\n";
23.
echo '<link>http://127.0.0.1/Rssnews/education_news/web_user/index.php<;/link>'."\n";
24.
echo '<lastBuildDate>'.date("D, d M Y H:i:s").'</lastBuildDate>'."\n";
25.
 
26.
 
27.
while($result = mysql_fetch_array($query)) {
28.
echo '<item>'."\n";
29.
echo '<title>'.$result[title].'</title>'."\n";
30.
echo '<description>'.$result[description].'</description>'."\n";
31.
echo '<link>'.$result[link].'</link>'."\n";
32.
echo '<pubDate>'.$result[pubdate].'</pubDate>'."\n";
33.
echo '</item>'."\n";
34.
}
35.
echo mysql_error();
36.
echo '</channel>'."\n";
37.
echo '</rss>'."\n";
38.
 
39.
 
หัวข้อ: Re: Creating a Custom RSS Feed with PHP and MySQL
เริ่มหัวข้อโดย: doramon ที่ กรกฎาคม 17, 2010, 11:15:24 AM
http://www.feedforall.com/sql2rss.htm
หัวข้อ: Re: Creating a Custom RSS Feed with PHP and MySQL
เริ่มหัวข้อโดย: doramon ที่ กรกฎาคม 17, 2010, 11:17:38 AM
http://www.techtoolblog.com/archives/rss-feed-any-mysql-database-using-php
หัวข้อ: Re: Creating a Custom RSS Feed with PHP and MySQL
เริ่มหัวข้อโดย: supannee2012 ที่ เมษายน 09, 2013, 11:40:23 AM
 :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[






"ชีวิต (http://snbbet.com)เป็น (http://casino9999.com)ของ (http://casino-slotonline.com)เรา (http://worldbet88.com)"