Simple search (in theory)
Posted: Tue Apr 24, 2007 1:43 am
Hi there
I have a working search page using PHP/MYSQL the problem is with the query below
Im using 3 test records one of which is the movie The Fifth Element, using the current query if i enter 'fifth' into my search it returns all 3 results (the other 2 are The Matrix and The Matrix Reloaded)
I have messed about with this removing the % etc which means you get no results unless the string matches exactly.
Just as a thought should I be using explode() on the string to check each word individually ( PHP Code question I know ) or is there a better way of wording the query
I have a working search page using PHP/MYSQL the problem is with the query below
Code: Select all
$query = "SELECT film_id, film_title, film_actors, film_description, film_year, film_location, film_backup FROM films WHERE (film_title LIKE '%$trimmed_title%' OR film_actors LIKE'%$trimmed_name%' OR film_year LIKE'%$trimmed_year%') ORDER BY film_title";I have messed about with this removing the % etc which means you get no results unless the string matches exactly.
Just as a thought should I be using explode() on the string to check each word individually ( PHP Code question I know ) or is there a better way of wording the query