$mysqli = new mysqli('localhost','root','root','mysql1');
if($mysqli->connect_errmo){
die('数据库连接失败,原因是:'.$mysqli->connect_error);
}
$sql = 'select * from emp';
$result=$mysqli->query($sql);
if($result && $result->num_rows>0 ){
$rows = $result->fetch_all(MYSQLI_ASSOC);
print_r($rows);
}else{
echo '你查询的内容不存在或查询错误';
}