Help needed about search

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help needed about search

    Hi,

    I want to make a search option for my site. I know the basic search criteria. it search from 1 feild. but I need that it should search from 2-3 feild.

    example:

    My feild names are: moviename, artist, coartist, keyword.
    here keywords saves like: avengers, scarlet, tonny, (with comma).

    When i put a name on the search box, it should search from all these field and provide me the results. but all I came up with these

    PHP Code:
    $result mysql_query("SELECT * FROM `movie_info` WHERE `moviename` LIKE '%$q%' LIMIT 0 , 30");
    while (
    $row mysql_fetch_array($result)) {
    ---

    Can anyone help me out in this?

    #2
    If your given code is working for single field then try this
    PHP Code:
     $result mysql_query
    "SELECT * FROM `movie_info` WHERE `FIELDNAME1` LIKE '%
    $q %' LIMIT 0 , 30" );
     
    $result mysql_query
    "SELECT * FROM `movie_info` WHERE `FIELDNAME2` LIKE '%
    $q %' LIMIT 0 , 30" ); 
     
    $result mysql_query
    "SELECT * FROM `movie_info` WHERE `FIELDNAME3` LIKE '%
    $q %' LIMIT 0 , 30" ); 
    .
    .
     .
    $result mysql_query
    "SELECT * FROM `movie_info` WHERE `FIELDNAMES` LIKE '%
    $q %' LIMIT 0 , 30" ); 
    WHILE **********
    YOUR CODE**** 
    Hope it will work

    Comment


      #3
      Its needed to use JOIN so check this for example: SQL Tutorial - Join
      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

      Comment


        #4
        Originally posted by arnage View Post
        Its needed to use JOIN so check this for example: SQL Tutorial - Join
        My code will work fine if all fields are in single table...

        Comment


          #5
          PHP Code:
          $result mysql_query("SELECT * FROM `movie_info` WHERE `moviename` LIKE '%$q%' OR `artist` LIKE '%$q%' OR `coartist` LIKE '%$q%' OR `keyword` LIKE '%$q%' LIMIT 0 , 30"); 
          Advertise your mobile site for FREE with AdTwirl

          Comment


            #6
            Thanks gummy it works. Thanks all.

            Comment

            Working...
            X