|
|
|
อยากสร้างไฟล์ XML ด้วย PHP ครับ สวัสดีครับ ผมอยากสร้างไฟล์ XML ด้วย PHP แต่ว่าลองอ่านแล้วหลายๆเว็บก็ไม่ค่อยเข้าใจ |
|
|
|
|
|
|
|
<?php
header("Content-type: text/xml;charset=tis-620");
include("conn/conf.php");
$sql_news="SELECT * FROM news ORDER BY NewsID DESC ";
$result_news=mysql_query($sql_news);
echo "<?xml version=\"1.0\" encoding=\"tis-620\"?>";
echo "<rss version=\"2.0\">";
echo "<channel>";
echo "<title>¢èÒÇ
echo "<link>http://www.eta.co.th/eng/news.php</link>";
echo "<description>ETA RSS </description>";
echo "<lastBuildDate>".date('l dS \of F Y h:i:s A')." </lastBuildDate>";
echo "<generator>http://www.eta.co.th</generator>";
echo "<image>";
echo "<title>¡Ò÷ҧ¾ÔàÈÉáËè§Acirc;</title>";
echo "<url>http://www.eta.co.th/th/images/rss_image.gif</url>";
echo "<link>http://www.eta.co.th</link>";
echo "</image>";
While($row_news=mysql_fetch_array($result_news)) {
echo "<item>";
echo "<title>".$row_news['NewsTopic_th']."</title>";
echo "<description>".$row_news['NewsAbstract_th']."</description>";
echo "<link>http://www.eta.co.th/eng/newsdetail.php?NewsID=".$row_news['NewsID']."</link>";
echo "<pubDate>".$row_news['NewsDate']."</pubDate>";
echo "</item>";
}//while
echo "</channel>";
echo "</rss>";
?>
|
|
|
|
|
Date :
17 ก.ค. 2550 14:21:44 |
By :
กระแต |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณคุณ กระแตมากๆครับ
|
|
|
|
|
Date :
18 ก.ค. 2550 08:40:26 |
By :
จขกท |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
header("Content-type:text/xml; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
echo '<?xml version="1.0" encoding="utf-8"?>';
$objConnect = mysql_connect("localhost","root","root");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM images WHERE 1 ";
$objQuery = mysql_query($strSQL);
?>
<images>
<?
while($obResult = mysql_fetch_array($objQuery))
{
?>
<item>
<ImageID><?=$obResult["ImageID"];?></ImageID>
<ItemID><?=$obResult["ItemID"];?></ItemID>
</item>
<?
}
?>
</images>
<?
mysql_close($objConnect);
?>
|
|
|
|
|
Date :
2012-08-23 11:31:26 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|