Try to search your question here, if you can't find : Ask Any Question Now ?

Multiple search criteria return result by either all input of part input

HomeCategory: stackoverflowMultiple search criteria return result by either all input of part input
Avatarsourav asked 2 weeks ago

I know I am supposed to apply prepared statement, but at this stage I just want to get clear about the basic for multiple search criteria.

I have 3 criteria for users to query, if users input 3 criteria conditions then my code returns the correct result. But when the user only input 1 criteria then my code return records not found.

I have tried to include (is set) in the criteria but I find conflicting with (is set) in summit button.

if (isset($_POST['submit'])){

$status = $_POST['status'];
$area = $_POST['area'];
$address = $_POST['address'];

if($status != "" OR $area != "" OR $address != ""){
$query = "SELECT * FROM `tbl_name` WHERE address LIKE '%".$address."%' 
AND status LIKE '%".$status."%' AND area = '$area' ";
}

I expect users can get the results either input in the all 3 search criteria, or only any 2 criteria or only any 1 criteria.

But my case only input all 3 only can return correct answers.

1 Answers
Best Answer
AvatarJyoti answered 2 weeks ago
Your Answer

7 + 10 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com