时间:2021-09-10 编辑:
<?php
class db{
//$res = mysqli_connect('localhost','root','root','bbb');
//public $connect='连接成功';
//public $sql="select user.user_name,user.pass,U_information.phonenumber,U_information.address from user inner join U_information";
//public function connect($res,$sql,$connect){
public function connect($res){
if($res){
//$res = mysqli_connect('localhost','root','root','bbb');
$sql="select user.user_name,user.pass,U_information.phonenumber,U_information.address from user inner join U_information";
$connect='连接成功';
echo $connect;
$bb=mysqli_query($res,$sql);
$arr=mysqli_fetch_assoc($bb);
echo '表中的字段信息为:';
echo '
';
var_dump($arr);
echo '
';
echo '该表各个字段的的详细信息为:';
while($arr=mysqli_fetch_assoc($bb)){
echo '
';
var_dump($arr);
}
}
else{
echo '连接失败,请重试!';
}
}
}
$obj=new db;
$res = mysqli_connect('localhost','root','root','bbb');
//$sql="select user.user_name,user.pass,U_information.phonenumber,U_information.address from user inner join U_information";
//$connect='连接成功';
//$obj->connect($res,$sql,$connect);
$obj->connect($res);
附上截图: