sir pannels
07-25-2008, 11:11 AM
hi all,
O.K after maybe abit of a brainstorm here regarding searching mysql.
I have a field... decription.... in that varchar field is around 10-100 characters describing that row. I wrote a search that just took a search term.. for example... blue shoes ... and puts that directly into a query..
SELECT this FROM that WHERE description LIKE '%$search_term%'
That is all well and good .. however some of the data is untidy ... in some cases you have rows with a decsription of either blue shoes or even shoes blue .. so the LIKE %% does not find all blue shoes description.. so I then used explode to get each word from the search term and then did a foreach word a sperate LIKE %% in the query... the problem I know have is that I now return rows for blue shoes,shoes blue, blue, shoes.. idealy i wouldnt have results for just blue and shoes.. having those results would not matter too much if I was able to weight the results some how.. order them so that the results with the most matches are at the top etc.
Anyone have any thoughts on what I'm trying to pull off here?
cheers all,
Sir P :D
O.K after maybe abit of a brainstorm here regarding searching mysql.
I have a field... decription.... in that varchar field is around 10-100 characters describing that row. I wrote a search that just took a search term.. for example... blue shoes ... and puts that directly into a query..
SELECT this FROM that WHERE description LIKE '%$search_term%'
That is all well and good .. however some of the data is untidy ... in some cases you have rows with a decsription of either blue shoes or even shoes blue .. so the LIKE %% does not find all blue shoes description.. so I then used explode to get each word from the search term and then did a foreach word a sperate LIKE %% in the query... the problem I know have is that I now return rows for blue shoes,shoes blue, blue, shoes.. idealy i wouldnt have results for just blue and shoes.. having those results would not matter too much if I was able to weight the results some how.. order them so that the results with the most matches are at the top etc.
Anyone have any thoughts on what I'm trying to pull off here?
cheers all,
Sir P :D