Php 搜寻及;匹配数据库中的数据,然后显示结果 if(isset($\u请求['submit'])) { $desg=$_POST['desg']; $cities=$_POST['cities']; $exp=$_POST['exp']; $prof=$_POST['prof']; $sql=“从adjob中选择*,其中类似于“%”$desg.“%”的设计或类似于“%”$cities.“%”的城市或类似于“%”$exp.“%”的经验或类似于“%”$prof.“%”的教授; $q=mysqli_查询($con,$sql); } 其他的 { $sql=“从adjob中选择*”; $q=mysqli_查询($con,$sql); } 剥皮 城市 经验 轮廓 设计 城市 费用 教授
我正在使用此代码从表中搜索。我必须填写4个字段才能获取一行的数据。。如何填写两个或三个字段并匹配数据库和搜索数据中的列(我们在各种工作门户中搜索的方式)??提前感谢/您可以根据用户输入创建搜索模式,如下所示:Php 搜寻及;匹配数据库中的数据,然后显示结果 if(isset($\u请求['submit'])) { $desg=$_POST['desg']; $cities=$_POST['cities']; $exp=$_POST['exp']; $prof=$_POST['prof']; $sql=“从adjob中选择*,其中类似于“%”$desg.“%”的设计或类似于“%”$cities.“%”的城市或类似于“%”$exp.“%”的经验或类似于“%”$prof.“%”的教授; $q=mysqli_查询($con,$sql); } 其他的 { $sql=“从adjob中选择*”; $q=mysqli_查询($con,$sql); } 剥皮 城市 经验 轮廓 设计 城市 费用 教授,php,search,mysqli,Php,Search,Mysqli,我正在使用此代码从表中搜索。我必须填写4个字段才能获取一行的数据。。如何填写两个或三个字段并匹配数据库和搜索数据中的列(我们在各种工作门户中搜索的方式)??提前感谢/您可以根据用户输入创建搜索模式,如下所示: <?php if (isset($_REQUEST['submit'])) { $desg = $_POST['desg']; $cities = $_POST['cities']; $exp = $_POST['exp']; $prof = $_P
<?php
if (isset($_REQUEST['submit'])) {
$desg = $_POST['desg'];
$cities = $_POST['cities'];
$exp = $_POST['exp'];
$prof = $_POST['prof'];
$sql = "SELECT * FROM adjob WHERE ";
$flag = FALSE;
if (isset($desg) && $desg != "") {// condition for desg
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $desg . "%'";
$flag = TRUE;
}
if (isset($cities) && $cities != "") { // condition for cities
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $cities . "%'";
$flag = TRUE;
}
if (isset($exp) && $exp != "") {// condition for exp
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $exp . "%'";
$flag = TRUE;
}
if (isset($prof) && $prof != "") {// condition for prof
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $prof . "%'";
$flag = TRUE;
}
$q = mysqli_query($con, $sql);
} else {
$sql = "SELECT * FROM adjob";
$q = mysqli_query($con, $sql);
}
您可以根据用户输入创建搜索模式,如下所示:
<?php
if (isset($_REQUEST['submit'])) {
$desg = $_POST['desg'];
$cities = $_POST['cities'];
$exp = $_POST['exp'];
$prof = $_POST['prof'];
$sql = "SELECT * FROM adjob WHERE ";
$flag = FALSE;
if (isset($desg) && $desg != "") {// condition for desg
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $desg . "%'";
$flag = TRUE;
}
if (isset($cities) && $cities != "") { // condition for cities
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $cities . "%'";
$flag = TRUE;
}
if (isset($exp) && $exp != "") {// condition for exp
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $exp . "%'";
$flag = TRUE;
}
if (isset($prof) && $prof != "") {// condition for prof
if (!$flag) {
$or = "";
} else {
$or = "OR";
}
$sql.=" $or desg like '%" . $prof . "%'";
$flag = TRUE;
}
$q = mysqli_query($con, $sql);
} else {
$sql = "SELECT * FROM adjob";
$q = mysqli_query($con, $sql);
}
希望这对您有用
if(isset($_REQUEST['submit']))
{
$desg = isset($_POST['desg']) ? $_POST['desg'] : '';
$cities = isset($_POST['cities']) ? $_POST['cities'] : '';
$exp = isset($_POST['exp']) ? $_POST['exp'] : '';
$prof = isset($_POST['prof']) ? $_POST['prof'] : '';
$sql = "SELECT * FROM adjob WHERE desg like '%".$desg."%' OR desg like '%".$desg."' OR desg like '".$desg."%' OR cities like '%".$cities."%' OR cities like'".$cities."%' OR cities like '%".$cities."' OR exp like '%".$exp."%' OR exp like '".$exp."%' OR exp like '%".$exp."' OR prof like '%".$prof."%'";
$q=mysqli_query($con, $sql);
}
else
{
$sql="SELECT * FROM adjob";
$q=mysqli_query($con, $sql);
}
?>
<form method="post">
<table width="200" border="1">
<tr>
<td>Desgination</td>
<td><input type="text" name="desg" value="" /></td>
<td>City</td>
<td><input type="text" name="cities" value="" /></td>
<td>Experince</td>
<td><input type="text" name="exp" value="" /></td>
<td>Profile</td>
<td><input type="text" name="prof" value="" /></td>
<td><input type="submit" name="submit" value="Find" /></td>
</tr>
</table>
</form>
<table>
<tr>
<td>Desg</td>
<td>Cities</td>
<td>Exp</td>
<td>Prof</td>
</tr>
<?php
while($res=mysqli_fetch_array($q)){
?>
<tr>
<td><?php echo $res['desg']; ?></td>
<td><?php echo $res['cities']; ?></td>
<td><?php echo $res['exp']; ?></td>
<td><?php echo $res['prof']; ?></td>
</tr>
<?php }?>
</table>
if(isset($\u请求['submit']))
{
$desg=isset($_POST['desg'])?$_POST['desg']:'';
$cities=isset($_POST['cities'])?$_POST['cities']:'';
$exp=isset($_POST['exp'])?$_POST['exp']:'';
$prof=isset($_POST['prof'])?$_POST['prof']:'';
$sql=“从adjob中选择*,其中类似于“%”的设计“%$desg.”或类似于“%”的设计“%$desg.”或类似于“%”的设计“%$desg.”或类似于“%$cities.”的城市“%$cities.”或类似于“%”的设计“%$exp.”或类似于“%$exp.”或类似于“%$exp.”的设计“%$exp.”或类似于“%$prof.”;
$q=mysqli_查询($con,$sql);
}
其他的
{
$sql=“从adjob中选择*”;
$q=mysqli_查询($con,$sql);
}
?>
剥皮
城市
经验
轮廓
设计
城市
费用
教授
希望这对您有用
if(isset($_REQUEST['submit']))
{
$desg = isset($_POST['desg']) ? $_POST['desg'] : '';
$cities = isset($_POST['cities']) ? $_POST['cities'] : '';
$exp = isset($_POST['exp']) ? $_POST['exp'] : '';
$prof = isset($_POST['prof']) ? $_POST['prof'] : '';
$sql = "SELECT * FROM adjob WHERE desg like '%".$desg."%' OR desg like '%".$desg."' OR desg like '".$desg."%' OR cities like '%".$cities."%' OR cities like'".$cities."%' OR cities like '%".$cities."' OR exp like '%".$exp."%' OR exp like '".$exp."%' OR exp like '%".$exp."' OR prof like '%".$prof."%'";
$q=mysqli_query($con, $sql);
}
else
{
$sql="SELECT * FROM adjob";
$q=mysqli_query($con, $sql);
}
?>
<form method="post">
<table width="200" border="1">
<tr>
<td>Desgination</td>
<td><input type="text" name="desg" value="" /></td>
<td>City</td>
<td><input type="text" name="cities" value="" /></td>
<td>Experince</td>
<td><input type="text" name="exp" value="" /></td>
<td>Profile</td>
<td><input type="text" name="prof" value="" /></td>
<td><input type="submit" name="submit" value="Find" /></td>
</tr>
</table>
</form>
<table>
<tr>
<td>Desg</td>
<td>Cities</td>
<td>Exp</td>
<td>Prof</td>
</tr>
<?php
while($res=mysqli_fetch_array($q)){
?>
<tr>
<td><?php echo $res['desg']; ?></td>
<td><?php echo $res['cities']; ?></td>
<td><?php echo $res['exp']; ?></td>
<td><?php echo $res['prof']; ?></td>
</tr>
<?php }?>
</table>
if(isset($\u请求['submit']))
{
$desg=isset($_POST['desg'])?$_POST['desg']:'';
$cities=isset($_POST['cities'])?$_POST['cities']:'';
$exp=isset($_POST['exp'])?$_POST['exp']:'';
$prof=isset($_POST['prof'])?$_POST['prof']:'';
$sql=“从adjob中选择*,其中类似于“%”的设计“%$desg.”或类似于“%”的设计“%$desg.”或类似于“%”的设计“%$desg.”或类似于“%$cities.”的城市“%$cities.”或类似于“%”的设计“%$exp.”或类似于“%$exp.”或类似于“%$exp.”的设计“%$exp.”或类似于“%$prof.”;
$q=mysqli_查询($con,$sql);
}
其他的
{
$sql=“从adjob中选择*”;
$q=mysqli_查询($con,$sql);
}
?>
剥皮
城市
经验
轮廓
设计
城市
费用
教授
是!!如果用户只选择两个输入或一个输入,它也会工作,但当我输入两个或三个输入时,它会显示错误..:(警告:mysqli_fetch_array()期望参数1是mysqli_结果,布尔值给定
我在这里得到这个错误
我应该回显它的数据还是只回显$sql;?在mysqli_查询之前回显$sql!!是!!如果用户只选择两个输入或一个输入,它也会工作,但当我输入两个或三个输入时,它会显示错误..:(警告:mysqli_fetch_array()期望参数1是mysqli_result,给定布尔值
我在这里得到这个错误
我应该回显它的数据还是回显$sql;?在mysqli_查询之前回显$sql!!