hi, i have a Searching SQL Query: $sql=mysql_query("SELECT * FROM products WHERE (code LIKE '%$sr%' OR model LIKE '%$sr%' OR manuf LIKE '%$sr%' OR keywords LIKE '%$sr%') AND status=1"); PHP: I want to search my database by those criteria: all of the words the exact phrase at least one of the words
your query must be dynamic if your going for advanced search, i mean specified searching.. this might not work accurately..
for example there should be some radio button(not necessarily radio button, text boxes, checkboxes, etc...).. ie. - lastname, firstname or add more criterias ie. - location, city, then execute a condition that if one of these criteria is empty or not then form a string. i mean, if location is not specified then $string = ''; thus, all criterias that is specified or is not empty should be set, ie, if !empty($location) then $string .= 'and location = $location'; put it all up and it will construct your query mysql_query($string); you cant get accurate results if your not filtering your query fields. hope that this helps. PS. beware of sql injections..