注意大写SQL语句
1.连接数据库
$con=mysqli_connect("localhost","admin","123456","ljm_web");
地址 账号 密码 数据库名
if (mysqli_connect_errno($con))
{
echo "连接 MySQL 失败: " . mysqli_connect_error();
}
2.增加
mysqli_query($con,"SELECT * FROM ljm_liuyan");
mysqli_query($con,"INSERT INTO ljm_liuyan (wen,uid,kind) VALUES ( '$wen', '$uid' , '$sa')"); //INSERT INTO ljm_liuyan (name, url, alexa, country)VALUES ('百度','https://www.baidu.com/','4','CN')
mysqli_close($con);
3.查询
$ljmsql3="SELECT * FROM `ljm_admin` WHERE ljm_aid = ".$adminid;
$ljmres3=mysqli_query($conn,$ljmsql3);
if (!$ljmres3) {
echo '<script>alert("数据出现问题");location.href="index.php";</script>';
}
$tourresult = $ljmres3->fetch_array() ?? ''; // 查询出来的对象 转为数组
var_dump($tourresult);
die;