幫助我創造這樣一個XML格式:如何添加節點生成XML文件
http://telkomvision.com/soap/timetable/monday.xml
,我犯了這樣的代碼:
<?php
date_default_timezone_set("Asia/Jakarta");
$NowDate = date("Y-m-d G:i:s");
$FormatWM = date('Y-m-d',strtotime($NowDate));
$FormatLagi = date('Y-m-d',strtotime($NowDate));
mysql_connect("localhost", "root", "");
mysql_select_db("telkncom_epg");
$namaTabel = "epg";
header('Content-Type: text/xml');
$query = "SELECT * FROM $namaTabel where tgl_mulai='26-SEP-12' limit 0,30";
$hasil = mysql_query($query);
$jumField = mysql_num_fields($hasil);
echo "<?xml version='1.0' ?>";
echo "<data>";
while ($data = mysql_fetch_array($hasil))
{
echo "<".$namaTabel.">";
for ($i=0; $i<=$jumField-1; $i++)
{
$namaField = mysql_field_name($hasil, $i);
echo "<".$namaField.">".$data[$namaField]."</".$namaField.">";
}
echo "</".$namaTabel.">";
}
echo "</data>";
?>
而且我的代碼結果是:
http://telkomvision.com/soap/timetable/CreateXML.php
我的數據庫設計:
| id | channel_code | channel_name |日期| s_time | e_time |主題| sinps |
我應該更改我的代碼以獲得我想要的結果?
不明白是什麼問題。你有一個格式良好的XML? – artragis