PDA

View Full Version : searching a mysql table with php, no just select statement


sir pannels
04-10-2003, 01:31 PM
Hey,
umm ok im workin or workin out the teory to work up a search script here.
so that if whats eneterd in the form lets call it "name" is included in a table feild record it returns the info for that record.
now I could do this with a SELECT * FROM table WHERE fieldname='$name' but then it will only return exact results, i wana try and work out a broader search
does anyone have any tuts? links? advice?
cheers :thumbsup:
Sir P

duniyadnd
04-10-2003, 01:41 PM
Don't quite understand what you're looking for, but for a broader search for the table, you remove the part of the query that is asking the specific information.

So:


SELECT * FROM table1


is as broad of a search you can get.

Duniyadnd

raf
04-10-2003, 02:47 PM
Searching on MySQL? Check out this

http://www.informit.com/isapi/product_id~{60B19985-0F7B-4E72-88ED-C472616E45D8}/element_id~{5EAC69E4-03DA-4A80-822F-F068D1381E8F}/st~{822202F4-E865-472D-B32F-BE77D3B7ACE1}/session_id~{09BA2F29-66C6-4746-85F9-E93947975ECB}/content/articlex.asp
(copy and paste url in necessary)

About your punctual question. Think your looking for the 'like' operator, but i'm not sure it can be used for MySQL for variable-values. MySQL site didn't turn up anything on that :(

But this does :)

http://www.science.uva.nl/mirror/mysql/manual_Reference.html

look for (edit-find-):
SELECT * FROM tbl_name WHERE set_col LIKE '%value%'