php连接mysql

2021-09-10 1948

<?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);

附上截图:

以上就是php连接mysql的详细内容,更多请关注php知识-学习天地 www.lxywzjs.com其它相关文章!

分享至:

分享到QQ空间 分享到朋友社区 新浪微博分享

栏目地图