时间:2021-07-01 10:21:17 帮助过:9人阅读
$mysqli=new mysqli("localhost","root","123456","test");
if($mysqli->connect_error){
die("连接失败".$mysqli->conect_error);
}
$sql="select * from user1";
$res=$mysqli->query($sql);
while($row=$res->fetch_row()){
foreach($row as $k=>$v){
echo "--$v";
}
echo "";
}
$res->free();
$mysqli->close();
$mysqli=mysqli_connect("localhost","root","123456","test");
if(!$mysqli){
die("连接失败".mysqli_connect_error($mysqli));
}
$sql="select * from user1";
$res=mysqli_query($mysqli,$sql);
while($row=mysqli_fetch_row($res)){
foreach($row as $k=>$v){
echo "--$v";
}
echo "";
}
mysqli_free_result($res);
mysqli_close($mysqli);