[请益] 导出MYSQL的值

楼主: Smallxiami (我在飞)   2015-04-12 05:01:06
※ 引述《Smallxiami (我在飞)》之铭言:
: 想请教一下
: 目前已完成一个PHP的网页 以连结上MYSQL 可以和MYSQL同步 并将MYSQL里面的资料显
: 示到页面上
: http://203.145.207.62/web003/
: 目前想实现一个目标 就是将GPS的值 和Dtime的值导出 变成一个参数 可以在html的
: 语法内使用 想要让资料表里面的座标 会自动在地图上标示出来 目前只能用手动输入
: 想请益有无方向 目前是无头绪中 新手刚接触 如果解释不详细 请推文告知
: 感谢
以参照

目前是做到 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();
?>
作者: tkdmaf (皮皮快跑)   2015-04-12 11:29:00
你的程式码中有一个在判断PHP6的那个判断没必要假设你真的有用到php6就只是自找麻烦了。另外mysql_fetch_assoc前面有@,你是打算预期他会出错吗?
作者: fri13 (思考跳tone记性差)   2015-04-12 18:30:00
你用dreamweaver在写PHP吗XD
楼主: Smallxiami (我在飞)   2015-04-12 22:36:00
没错 我用dw
作者: tkdmaf (皮皮快跑)   2015-04-12 23:00:00
所以你是看DW&PHP的书?

Links booklink

Contact Us: admin [ a t ] ucptt.com