-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct_U_api.php
More file actions
38 lines (27 loc) · 855 Bytes
/
product_U_api.php
File metadata and controls
38 lines (27 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
// {
// "id":"XX",
// "pname":"XX",
// "pdimg":"XX",
// "information":"XX",
// "price":"XX"
// }
require_once("conn.php");
$data = file_get_contents("php://input","r");
$jsonData = array();
$jsonData = json_decode($data,true);
$id = $jsonData["id"];
$pname = $jsonData["pname"];
$pdimg = $jsonData["pdimg"];
$information = $jsonData["information"];
$price = $jsonData["price"];
$sql = "UPDATE `product` SET `Pname` = '$pname', `Pdimg` = '$pdimg', `Information` = '$information' , `Price` = '$price' WHERE `Product`.`ID` = '$id';";
mysqli_query($conn,'SET NAMES utf8');
if(mysqli_query($conn, $sql)){
echo('{"state":true,"message":"更新資料成功"}');
}
else{
echo('{"state":false,"message:更新資料失敗'.$sql.mysqli_error($conn).'}');
}
mysqli_close($conn);
?>