Anyone want to help me to show how make a search with multiple words and condition like or and not..
google search..
Thanks for read my thread..
Ardy Satria H
>email address snipped<

Recommended Answers

All 2 Replies

You can first create a variable as array like
$query_array=array();

Then u can assign the conditions to these array as string like this..

If ($mob!=' '){
$query_array[]=" personal_mob1 =' ".$mob." 'OR personal_mob2= ' ".$mob." ' ";
}
If ($ser!=' '){
$query_array[]="personal_service1=' ".$ser." ' OR personal_service2=' ".$ser." 'personal_service3=' ".$ser." ' ";
}

// Here $mob and $ser are the variables that get their values from $_post[‘’]
// U want to enter all the fields that u want to search to the $query_array variable..

Now u want to combine these string by the function implode() like…
$query_string=implode("AND", $query_array);

Now u can enter the $query_string variable after the WHERE CALUSE as conditions. Like

SELECT * FROM personal WHERE $query_string;

This will give result satisfying the search criteria..

Hope u can now search anything u want !!
Cheers
Jino..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.