Help needed about search

Started on the old forum in February 2013 · view the original in the archive · old links redirect here

5 replies · 605 views · started 13 years ago · 1 min read

4 participants
asifnayem Developer · 119 posts #1

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

$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?

pankajb Junior · 12 posts #2

If your given code is working for single field then try this

 $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

arnage Lead · 811 posts #3

Its needed to use JOIN so check this for example: SQL Tutorial - Join

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
GumSlone Administrator Principal · 1,690 posts #5
$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

External image (may be gone)

asifnayem Developer · 119 posts #6

Thanks gummy 🙂 it works. Thanks all.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close