<?php
$id = $_GET[‘id‘];
$conn = new mysqli(‘localhost‘,‘root‘,‘root‘,‘ceshi‘);
if ($_POST){
$title = trim($_POST[‘title‘]);
$uname = $_POST[‘img‘];
$descs = $_POST[‘desc‘];
$content = $_POST[‘content‘];
$conn = new mysqli(‘localhost‘,‘root‘,‘root‘,‘ceshi‘);
$sql = "update product set title=‘$title‘,img=‘$uname‘,descs=‘$descs‘,content=‘$content‘ where id = $id ";
//如当时添加新数据,不过这里的sql语句是update更新数据
$res = $conn->query($sql);
//执行sql语句
if($conn->error){
die($conn->error);
}
if($res){
header(‘location: product.php‘);
//完成后跳转到产品展示界面
}else{
echo $res;
}
}
$sql = "select * from product where id = $id";
$res = $conn->query($sql);
$info = $res->fetch_assoc();
$conn->close();
?>