我在数据库中有一个 user_privilege 列,如下所示:
username user_privilege
a 7gz,agt_courses,newbill
b dataDisplay,previllige,newUsers
c newbill,dataDisplay,previllige
我想搜索我OR
在每个之间使用的 user_privilege 列中的每个值,FIND_IN_SET
但我的工作不正确?
我写了php代码:
ob_start();
session_start();
$username = $_POST['username'];
$username2 = $_POST['username2'];
$finduser = mysqli_query($link,"SELECT * FROM LOGIN
WHERE username='".$username."' AND username2='".$username2."'
AND FIND_IN_SET('7gz', user_previllige) OR FIND_IN_SET('agt_courses',user_previllige) OR FIND_IN_SET('newbill',user_previllige) OR FIND_IN_SET('new_Trainee',user_previllige)OR FIND_IN_SET('dataDisplay',user_previllige) OR FIND_IN_SET ('previllige',user_previllige) OR FIND_IN_SET('newUsers',user_previllige) OR FIND_IN_SET('Customers ',user_previllige )")
or die("error");
if(mysqli_num_rows($finduser) !=0)
{
while($row = mysqli_fetch_array($finduser))
{$uname = $row['username'];
$uname2 = $row['username2'];
$arr=explode(",",$row['user_previllige']);
//if($arr=='dataDisplay'){echo 'yes';}//elseif($arr=='new_Trainee'){echo 'yes';}
}
}
if($username == $uname && $username2 == $uname2)
{$_SESSION['sessionname'] =$uname;
$_SESSION['sessionname2'] =$uname2;
$_SESSION['sessionpre'] =$arr;
header ("location:../agtSite/agt2 - Copy.php");
//echo '<meta http-equiv="refresh" content="1" url="../agtSite/agt2 - Copy.php"/>';
}
else echo 'اسم المستخدم غير موجود <a href="login.php"> اذهب للتسجيل مره اخري </a> ';
}
ob_end_flush();
但它不能正常工作有多重搜索的解决方案吗??????