我想使用MYSQL连接在两个表上创建搜索现在我想要过滤一些我从数据库调用的变量。
这个SQL查询获取所有内容并粘贴在我的屏幕上
$sql2 = "select pinfo.*, einfo.*
from profile_info pinfo , education_info einfo
where pinfo.username = einfo.username";
现在我想过滤一些变量,比如全名,出生日期,性别,地点和简历,INSTIT_name
现在信息保存在两个表上,我在编写这个确切的查询时遇到问题,以过滤两个表
profile_info education_info
profile_info有这个列 用户名
file_name
file_size
file_type
tmp_name
photograph_name
photograph_size
photograph_type
photographtmp_name
fullname
address
address2
city
state
email
tel
state_origin
lga
marital_status
dob
教育信息有这个专栏
username
inst_name
inst_name2
grade
study_course
qualification
other_qualification
completion_year
现在在MYSQL中使用LIKE我如何能够过滤以获得足够的结果。
到目前为止,我写的代码看起来像这样
<?php
if(isset($_POST['search_button']))
{
require_once('inc/config.php');
$con = mysqli_connect($host,$user,$pass,$db) or die ('Cannot Connect: '.mysqli_error());
$sql = "select ";
$result = mysqli_query($con,$sql) or die("Error: ".mysqli_error($con));
while( $row = mysqli_fetch_array( $result, MYSQLI_ASSOC ) ){
echo "
<tr>
<td width=248 align=center>
<font face=Verdana size=2>".$row['fullname']."</font></td>
<td align=center><font face=Verdana size=2>".$row['dob']."</font></td>
<td align=center><font face=Verdana size=2>".$row['gender']."</font></td>
<td align=center><font face=Verdana size=2>".$row['location']."</font></td>
<td align=center><font face=Verdana size=2>
".$row['resume']."</font></td>
</tr>";
}
}
?>
答案 0 :(得分:0)
尝试这个。
示例从profile_info获取全名,地址以及来自education_info
的成绩和资格 $sql2 = "select profile_info.fullname as n,
profile_info.address as a,
education_info.grade as g,
eduction_info.qualification as q
from profile_info inner join education info on profile_info.username=education_info.username";