I have a script that searches for users in the db. I have two input fields so that I can search for e.g. city and house number. What I want is that if I type e.g. London in the city field and the number 20 it returns the record with London AND 20 in it. I’m not quite sure how to achieve this. I did enough research on Google but still didn’t find the answer.
Here is my code:
if($_GET['search'] != ''){
$result = mysql_query("SELECT * FROM klant WHERE klant_id LIKE '%" .$search."%' OR voornaam LIKE '%" .$search."%' OR achternaam LIKE '%" .$search."%' OR email LIKE '%" .$search."%' OR plaats LIKE '%" .$search."%' OR bedrijfsnaam LIKE '%" .$search."%'ORDER BY klant_id DESC");
$result2 = mysql_query("SELECT * FROM klant WHERE klant_id LIKE '%" .$search2."%' OR voornaam LIKE '%" .$search2."%' OR achternaam LIKE '%" .$search2."%' OR email LIKE '%" .$search2."%' OR plaats LIKE '%" .$search2."%' OR bedrijfsnaam LIKE '%" .$search2."%'ORDER BY klant_id DESC");
$i = 0;
}
What I need is something that will give the proper $result where those two search values ($search and $search2) are combined. Thus allowing me to search much easier.
Hope that i phrased my question well enough for you to understand me and I hope that you can help me!
Please try with the following logic –