Hi,
I'm trying to search my database where the user select a phrase, as long as any word matches, the record will display..
This is a stupid way I have... since very likely the value I have will be within 4 words, I can do the if statement 5 times.. like this:
eg: $model = 'book worm';
$explodemodel = explode(" ",$model);
for ($i=0;$i<count($explodemodel);$i++)
{
$expmodels[$i]= $explodemodel[$i];
}
if (count($explodemodel) = 0) {
$models = 'model LIKE ' .'%explodemodel[0]%';
}
elseif (count($explodemodel) = 1) {
$models = 'model LIKE ' .'%explodemodel[0] . 'OR model LIKE' .'%explodemodel[1]%';
}
then SELECT * WHERE $models
isn't this stupid? what if the phrase has to consist of 100 words? How do I code it in a smarter way? help me out please!