数据库链接

$host='localhost';

$user='root';

$password='123456';
// 库名
$dbName='test';
// 链接数据库
$link=new mysqli($host,$user,$password,$dbName);

if ($link->connect_error){

die("连接失败:".$link->connect_error);

}

$sql="select * from t_emp";
// 发送sql语句
$res=$link->query($sql);
// 接收数据
$data=$res->fetch_all();

print_r($data);

posted on 2022-03-16 15:58  ||子义  阅读(21)  评论(0编辑  收藏  举报

导航