google 地图和 php+mysql 集合的例子(二)
Filed Under PHP post by 蜗牛爱吃巧克力 -pp815 / 2011-3-27 10:29
Sunday
接着 google 地图和 php+mysql 集合的例子(一) 将数据库的标记显示在地图上
面。
1、新建个 phpsqlajax_genxml.php 文件
<?php
require("conn.php");
mysql_query("set names 'GBK'"); // 使用 GBK中文编码 ;
error_reporting(0);
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml;charset=gb2312");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
评论0
最新资源