时间:2021-07-01 10:21:17 帮助过:22人阅读
$mysqli=new MySQLi("localhost","root","root","test");
if($mysqli->connect_error){
die("连接失败".$mysqli->connect_error);
}
//2.操作数据库(发送sql)
$sql="select *from user1";
$res=$mysqli->query($sql);
//3.处理结果
while($row=$res->fetch_row()){
foreach($row as $key=>$val){
echo "--$val";
}
echo "<br/>";
}
//4.关闭资源,连接
$res->free();
$mysqli->close();
mysqli操作mysql数据库(面向对象风格)
标签:mysqli mysql数据库