Presentation is loading. Please wait.

Presentation is loading. Please wait.

後端教學-MYSQL 講師:邱小楓(邱珈蓉)

Similar presentations


Presentation on theme: "後端教學-MYSQL 講師:邱小楓(邱珈蓉)"— Presentation transcript:

1 後端教學-MYSQL 講師:邱小楓(邱珈蓉)
资料下载: PPT课件下载: 范文下载: 试卷下载: Word教程: Excel教程: 优秀PPT下载: PPT教程: 节日PPT模板: PPT素材下载: PPT背景图片: PPT图表下载: PPT模板下载: 行业PPT模板: 教案下载: 後端教學-MYSQL 講師:邱小楓(邱珈蓉)

2 常見的SQL指令 Select - 查詢 Insert - 插入 Update - 更新 Delete - 刪除

3 連接資料庫 <?php $link =mysqli_connect('localhost','root','password');
mysqli_query($link,"SET NAMES utf8"); if (!$link) {  die(' 連線失敗,輸出錯誤訊息 : ' . mysql_error()); } echo ' 連線成功 '; ?>

4 妥善使用include

5 查詢資料 $sql=“select * from xxx”; $result = mysqli_query($link,$sql);
while($row=mysqli_fetch_array($result)) { echo $row[0] ; echo $row[1] ; echo $row[2] ; }

6 新增資料 $sql=“select * from xxx”; $result = mysqli_query($link,$sql);
$sql = "INSERT INTO `classtest`.`menu` (`id`, `name`, `price`, `description`, `type`, `ca`) VALUES (NULL, '".$fname."', '".$fp."', '".$des."', '".$pic."', '".$ca."');"; echo $sql."<br>"; $result = mysqli_query($conn,$sql);

7 修改資料 $sql=“select * from xxx”; $result = mysqli_query($link,$sql);
$sql ="UPDATE `menu` SET `name` = '".$name."', `price` = '".$price."',`ca` = '".$ca."', `description` = '".$descrip."',`type` = '".$pic."' WHERE `menu`.`id` = ".$fid.";"; echo $sql."<br>"; $result = mysqli_query($conn,$sql); //回傳true 跟flase

8 刪除資料 $sql=“select * from xxx”; $result = mysqli_query($link,$sql);
$sql = " DELETE FROM `menu` WHERE `id` = ".$fid.""; $result = mysqli_query($conn,$sql);


Download ppt "後端教學-MYSQL 講師:邱小楓(邱珈蓉)"

Similar presentations


Ads by Google