wamp5之php系列
<?php header("content-type:text/xtml;charset=utf-8");
?>
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("db_cartoon",$con);
mysql_query("SET NAMES 'UTF8'");
mysql_query("SET CHARACTER SET UTF8");
mysql_query("SET CHARACTER_SET_RESULTS=UTF8");
$sql="select * from web_cartoon_content";
$result=mysql_query($sql,$con);
//print_r(mysql_fetch_array($result,MYSQL_BOTH));
//mysql_close($con);
echo '<?xml version="1.0" encoding="utf-8"?>';
echo "\r\n";
echo "<books>";
echo "\r\n";
for($i=0;$i<mysql_num_rows($result);$i++){
echo "<book>";
echo "\r\n";
echo "<bookName>";
echo mysql_result($result,$i,"title");
echo "</bookName>";
echo "\r\n";
echo "<bookContent>";
echo mysql_result($result,$i,"content");
echo "</bookContent>";
echo "\r\n";
echo "<Writer>";
echo mysql_result($result,$i,"writer");
echo "</Writer>";
echo "\r\n";
echo "<countryName>";
echo mysql_result($result,$i,"country");
echo "</countryName>";
echo "\r\n";
echo "<coverPath>";
echo mysql_result($result,$i,"coverPath");
echo "</coverPath>";
echo "\r\n";
echo "<zipPath>";
echo mysql_result($result,$i,"zipPath");
echo "</zipPath>";
echo "\r\n";
echo "<classId>";
echo mysql_result($result,$i,"classId");
echo "</classId>";
echo "\r\n";
echo "<createTime>";
echo mysql_result($result,$i,"createTime");
echo "</createTime>";
echo "\r\n";
echo "<oid>";
echo mysql_result($result,$i,"oid");
echo "</oid>";
echo "<grade>";
echo mysql_result($result,$i,"grade");
echo "</grade>";
echo "\r\n";
echo "<gradeNums>";
echo mysql_result($result,$i,"gradeNums");
echo "</gradeNums>";
echo "\r\n";
echo "<hitnum>";
echo mysql_result($result,$i,"hitnum");
echo "</hitnum>";
echo "\r\n";
echo "<recommend>";
echo mysql_result($result,$i,"recommend");
echo "</recommend>";
echo "\r\n";
echo "<newest>";
echo mysql_result($result,$i,"newest");
echo "</newest>";
echo "\r\n";
echo "</book>";
echo "\r\n";
}
mysql_free_result($result);//释放结果内存
echo "</books>";
?>