※ 引述《Smallxiami (我在飞)》之铭言:
: 想请教一下
: 目前已完成一个PHP的网页 以连结上MYSQL 可以和MYSQL同步 并将MYSQL里面的资料显
: 示到页面上
: http://203.145.207.62/web003/
: 目前想实现一个目标 就是将GPS的值 和Dtime的值导出 变成一个参数 可以在html的
: 语法内使用 想要让资料表里面的座标 会自动在地图上标示出来 目前只能用手动输入
: 想请益有无方向 目前是无头绪中 新手刚接触 如果解释不详细 请推文告知
: 感谢
以参照 http://ppt.cc/Twmr
目前是做到 Using PHP's DOM functions to Output XML
此为 我目前的成果 http://203.145.207.62/web003/try005.php
似乎 错很大 麻烦帮忙一下 感谢
确定有连结到 mysql
程式码
<?php require_once('Connections/try001.php');
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$dom = new DOMDocument("1.0");
$node = $dom->createElement("try001");
$parnode = $dom->appendChild($node);
mysql_select_db($database_try001, $try001);
$query_Recordset1 = "SELECT * FROM try001 ORDER BY id DESC";
$Recordset1 = mysql_query($query_Recordset1, $try001) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = @mysql_fetch_assoc($Recordset1)){
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("try001");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name",$row['name']);
$newnode->setAttribute("address", $row['address']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['lng']);
$newnode->setAttribute("type", $row['type']);
}
echo $dom->saveXML();
?>