This is the music
. table It contains artists
and titles
. Artists are separated by commas if more than one artist sing a song. I want to set up a search function so users can search for one artist, both artists, no artists and title etc.
Table music
:
| artist | title |
|------------------------------|
|eminem,lil wayne | no love |
|kida | o'najr |
User may search like this:
eminem no love
lil wayne no love
no love eminem
no love lil wayne
Also user can or can not type special chars like '
if user search:
kida onajr
kida o najr
kida o'najr
the result should be the same.
This is my code up to now:
$search_value = "...";
$query = "select * from `music` where `title` like '%$search_value%' or `artist` like '%$search_value%'";
But if I search lil wayne no love
no results are shown.