l 1 My SQL Free My SQL Hosting

  • Slides: 17
Download presentation

資訊系統 開發實例 (楊子青) l 1. My. SQL資料庫 Free My. SQL Hosting – https: //www.

資訊系統 開發實例 (楊子青) l 1. My. SQL資料庫 Free My. SQL Hosting – https: //www. freemysqlhosting. net/ – Log in:輸入Email Address及Password – 進入資料庫管理介面

資訊系統 開發實例 (楊子青) l 2. PHP程式 上傳(新增)一筆記錄: update. php <? php header("Content-Type: text/html; charset=utf-8");

資訊系統 開發實例 (楊子青) l 2. PHP程式 上傳(新增)一筆記錄: update. php <? php header("Content-Type: text/html; charset=utf-8"); $con = mysqli_connect("sql 6. freemysqlhosting. net", "sql 6137525", "ub. URm. Rvk. ZI", "sql 6137525"); // Check connection if (mysqli_connect_errno()) { echo "無法連線到My. SQL: ". mysqli_connect_error(); } $user = $_POST['user']; $score = $_POST['score']; $current = $_POST['current']; // Perform queries $sql="INSERT INTO mouse (user, score, current) VALUES (CONVERT(_utf 8 '$user' USING utf 8), '$score', '$current')"; if (mysqli_query($con, $sql)){ echo "您的資料上傳成功"; } else { echo "您的資料上傳失敗"; } mysqli_close($con); ? >

資訊系統 開發實例 (楊子青) l PHP程式 查詢所有記錄: hero. php <? php header("Content-Type: text/html; charset=utf-8"); $con

資訊系統 開發實例 (楊子青) l PHP程式 查詢所有記錄: hero. php <? php header("Content-Type: text/html; charset=utf-8"); $con = mysqli_connect("sql 6. freemysqlhosting. net", "sql 6137525", "ub. URm. Rvk. ZI", "sql 6137525"); // Check connection if (mysqli_connect_errno()) { echo "無法連線到My. SQL: ". mysqli_connect_error(); } // Perform queries mysqli_query($con, "SET CHARACTER SET UTF 8"); $sql="SELECT * FROM mouse ORDER BY score DESC, current DESC"; $result = mysqli_query($con, $sql); $json = array(); if(mysqli_num_rows($result)){ while($row=mysqli_fetch_assoc($result)){ $json[]=$row; } } echo urldecode(json_encode($json)); mysqli_close($con); ? >

資訊系統 開發實例 (楊子青) l PHP程式 將php程式上傳到網頁空間,並確定網址,例如: – http: //www 1. pu. edu. tw/~tcyang/php/upload. php

資訊系統 開發實例 (楊子青) l PHP程式 將php程式上傳到網頁空間,並確定網址,例如: – http: //www 1. pu. edu. tw/~tcyang/php/upload. php – http: //www 1. pu. edu. tw/~tcyang/php/hero. php