数据库用户名是root
数据库密码是123456
数据库名是mydb
数据库里有个表mytab
有3个字段
id(主键) name sno
1 张三 123
2 李四 456
然后在项目根目录,新建一个文件:index.php
<?php
//连接数据库
$con=mysqli_connect("localhost","root","123456","mydb")
//SQL语句
$sql="select * from mytab"
//执行SQL语句,结果保存到$arr
$obj=mysqli_query($con,$sql)
$arr=mysqli_num_rows($result)
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=UTF-8">
<title>实现最简单的php网页+mysql查询功能</title>
</head>
<body>
<?php
echo "<pre>"
print_r($obj)
?>
</body>
</html>
之后就能够看到结果了
SELECT a.byear,a.bname,b.tname FROM data as a left join teacher on a.tid=b.tid where a.bname like '%xxxx%' and a.byear='xxxx' and b.tname like '%xxxx%'你的condition 只是where条件而已
依旧可以用,只不过,应该把内容中byear改成a.byear,tname 改成b.tname
SELECT a.*,b.tname FROM data as a left join teacher on a.tid=b.tid ".$condition." order by a.bid
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)