帮助我创建这样的 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
我的数据库设计:
| 编号 | 频道代码 | 频道名 | 日期 | s_time | e_time | 话题 | 罪孽 |
我应该在我的代码中进行哪些更改以获得我想要的结果?