Hello
Does anyone know how to effectively search for a string in a Mysql table?
Here's the problem:
Let's say I have a table(id,song) and I want to search for a specific song (ex: One Love)
Using the following query returns the exact song when the user enters it exactly as it is:
$mysearch = "One Love";
"SELECT id, songs FROM pages WHERE title = '" . mysql_real_escape_string($mysearch) . "'"
But the problem is, once the user enters some extra spaces between words the query doesn't seem to find that song anymore:
$mysearch = "One Love"; //with 3 spaces between 'One' and 'Love'
"SELECT id, songs FROM pages WHERE title = '" . mysql_real_escape_string($mysearch) . "'"
I've tried "preg_replace" to remove the extra spaces before submitting the search term but it doesn't seem to work? when printing the search term it looks ok though: "One Love" just like the one in the DB, but Mysql still can't seem to find it!
Please can I do this in a better way? any suggestion?
Help Please
Peace