[請益] 導出MYSQL的值

作者: Smallxiami (我在飛)   2015-04-12 05:01:06
※ 引述《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();
?>
作者: 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