记得数据库,root密码更改一下
<meta charset="UTF-8">
<?php
$dbhost = 'localhost:3306'; // mysql服务器主机地址
$dbuser = 'root'; // mysql用户名
$dbpass = 'root'; // mysql用户名密码
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('连接失败: ' . mysqli_error($conn));
}
// 设置编码,防止中文乱码
mysqli_query($conn , "set names utf8");
@$id = $_GET['id'];
$sql = "DELETE FROM brand
WHERE id='$id'";
mysqli_select_db( $conn, 'management' );
$retval = mysqli_query( $conn, $sql );
if(! $retval )
{
die('无法删除数据: ' . mysqli_error($conn));
}
echo ("<script>alert('删除成功');window.location.href= 'brand-all.php'; </script>");//跳转页面
mysqli_close($conn);
?>