jordanwb Posted March 19, 2008 Share Posted March 19, 2008 I'm making a jukebox and I want the user to be able to search the songs in the database by it's name. What I want to do is get all the songs whose name contains any of the words in the search term. I found out you can use Regex in a sense: SELECT * FROM `box_songs` WHERE `song_name` REGEXP 'Convoy' What I'd like to do is sort the result by the number of matches between the search terms and the songs in the database, most matches first. I was thinking of getting all the records which contains any of the words in the search terms then using substr_count and add up all the occurances then sorting. That would work but it may be slow and a bubble sort would be inefficient. Thanks. Link to comment https://forums.phpfreaks.com/topic/96991-need-help-with-creating-logic-for-searching-table/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.