how to create search engine by using explode function to get answer.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • classifieds
    New Member
    • Sep 2012
    • 1

    #1

    how to create search engine by using explode function to get answer.

    my code is here(it works but doesn't return result if i entered 1st keyword which is not in the database please help me))

    Code:
    $sqlSelect = "SELECT user_id,name,cat,product,descrip,price,Image FROM   tbl_user1 WHERE name like '%$result[0]%' OR name like '%$result[1]%' OR name like '%$result[2]%'
              or cat like '%$result[0]%' OR cat like '%$result[1]%' OR cat like '%$result[2]%' or
              product like '%$result[0]%' OR product like '%$result[1]%' OR product like '%$result[2]%'  or
              descrip like '%$result[0]%' OR descrip like '%$result[1]%' OR descrip like '%$result[2]%'";
              $sqlSelected=mysql_query($sqlSelect);
    Last edited by zmbd; Sep 29 '12, 02:30 PM. Reason: Please format your posted code using the <CODE/> button.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Are you sure all $result[] values do have a value, and are not NULL?

    and, shorter, would be:
    Code:
    WHERE concat(name, cat, product, descrip) like '%$result[0]%'
       OR concat(name, cat, product, descrip) like '%$result[1]%'
       OR concat(name, cat, product, descrip) like '%$result[2]%'
    To get into more details, some sample data would be nice...

    Comment

    Working...