[請益] 導出MYSQL的值

看板PHP作者 (我在飛)時間10年前 (2015/04/12 05:01), 10年前編輯推噓0(006)
留言6則, 3人參與, 最新討論串1/1
※ 引述《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(); ?> -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 49.159.186.96 ※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1428786070.A.24E.html ※ 編輯: Smallxiami (49.159.186.96), 04/12/2015 05:02:06

04/12 11:29, , 1F
你的程式碼中有一個在判斷PHP6的那個判斷沒必要
04/12 11:29, 1F

04/12 11:30, , 2F
假設你真的有用到php6就只是自找麻煩了。
04/12 11:30, 2F

04/12 11:33, , 3F
另外mysql_fetch_assoc前面有@,你是打算預期他會出錯嗎?
04/12 11:33, 3F

04/12 18:30, , 4F
你用dreamweaver在寫PHP嗎XD
04/12 18:30, 4F
※ 編輯: Smallxiami (49.159.186.96), 04/12/2015 22:36:18

04/12 22:36, , 5F
沒錯 我用dw
04/12 22:36, 5F

04/12 23:00, , 6F
所以你是看DW&PHP的書?
04/12 23:00, 6F
文章代碼(AID): #1LAOkM9E (PHP)
文章代碼(AID): #1LAOkM9E (PHP)