如何在PHP中的表中执行多搜索?
这是我的代码:
<form action="" method="GET">
<input type="text" class="span4" placeholder="Cari Nama" name="carinama" style="margin-top:10px;" />
<input type="text" class="span4" placeholder="Cari DOB" name="caridob" id="datepicker" autocomplete="off"style="margin-top:10px;" />
<input type="text" class="span4" placeholder="Cari Role" name="carirole" style="margin-top:10px;" />
<button class="btn btn-primary" type="submit"><i class="fa fa-save fa-fw"></i> Cari</button>
</form>
这是querynumber
:
</div>
</div>
<div class="row-fluid row-merge">
<?php
$querymember = "SELECT u.*, r.* FROM m_user u LEFT JOIN m_role r ON u.user_role = r.role_id ";
if(isset($_GET['carinama']))
{
$carinama = $_GET['carinama'];
$querymember .= " WHERE u.user_email LIKE '%$carinama%' OR u.user_fname LIKE '%$carinama%' OR u.user_mname LIKE '%$carinama%' OR u.user_lname LIKE '%$carinama%' OR u.user_uname LIKE '%$carinama%' OR u.user_fname LIKE '%$carinama%'";
echo "Filter : $carinama";
}
elseif(isset($_GET['caridob']))
{
$caridob = $_GET['caridob'];
$querymember .= " WHERE u.user_dob LIKE '%$caridob%'";
echo "Filter : $caridob";
}
elseif(isset($_GET['carirole']))
{
$carirole = $_GET['carirole'];
$querymember .= " WHERE r.role_name LIKE '%$carirole%'";
echo "Filter : $carirole";
}
$querymember .= " ORDER BY u.user_fname";
$result = mysqli_query($conn,$querymember);
$rpp = 10; // results per page
$_SESSION['filter']=$querymember;
$adjacents = 4;
我还是新手,所以我需要你的帮助。我将不胜感激。感谢。
答案 0 :(得分:0)
WHERE (lower(CONCAT(u.user_email,u.user_fname,u.user_mname,u.user_lname,u.user_uname,u.user_fname)) LIKE '%LOWER('.$carinama.')%')