$strSearch = !empty($_GET['txtsearch'])?
" WHERE (username LIKE '%".$_GET["txtsearch"]."%' or name LIKE '%".$_GET["txtsearch"]."%' or lastname LIKE '%".$_GET["txtsearch"]."%')":" where 1=1";
$sql = "select * from jos_users
inner join member on users.id = member.users_id
inner join acl_aro on users.id = acl_aro.value
inner join acl_groups_aro_map on acl_aro.id = acl_groups_aro_map.aro_id
$strSearch and level='M001' or level='U001'
order by member.group asc";
ติดปัญหาที่ and level='M001' or level='U001' ครับ Code (PHP)
$sql = "select * from users
left join member on users.id = member.users_id
left join acl_aro on users.id = acl_aro.value
left join acl_groups_aro_map on acl_aro.id = acl_groups_aro_map.aro_id
and level='M001' or level='U001'
order by member.group asc";
ผมลองลบ $strSearch and level='M001' or level='U001' ทั้งบรรทัดก็จะแสดงข้อมูลถูกต้องครับ Code (PHP)
$sql = "select * from users
left join member on users.id = member.users_id
left join acl_aro on users.id = acl_aro.value
left join acl_groups_aro_map on acl_aro.id = acl_groups_aro_map.aro_id
order by member.group asc";
แต่ถ้าผมลบ or level='U001' ก็จะแสดงข้อมูลถูกต้อง แต่กลุ่ม U001 ก็จะไม่แสดงนะครับ
Code (PHP)
$sql = "select * from users
left join member on users.id = member.users_id
left join acl_aro on users.id = acl_aro.value
left join acl_groups_aro_map on acl_aro.id = acl_groups_aro_map.aro_id
and level='M001'
order by member.group asc";
Code (PHP)
$sql = "select * from users
left join member on users.id = member.users_id
left join acl_aro on users.id = acl_aro.value
left join acl_groups_aro_map on acl_aro.id = acl_groups_aro_map.aro_id
and level='M001' or level='U001'
order by member.group asc";