PDA

View Full Version : PHP/MySQL database search



Daniel Hollands
January 30th, 2001, 18:30
Can anyone tell me the code to do a mySQL search using PHP please?

For example we could say that the field name is $keywords, the user would be able to type in some keywords, and get a list of documents relating to the search term.

Any idears?

PS, I’m very sorry if this is a basic task, but I’m still learning PHP :)

Woofcat
January 30th, 2001, 19:37
Parsing a list of keywords for a search engine type script will be too difficult for you if you don't know the basics...

BillWill
January 30th, 2001, 20:11
mysql_query("SELECT id, site, url, description FROM table WHERE site LIKE '$keyword' OR description LIKE '$keyword' ORDER BY site ASC");


Visit http://www.php.net/mysql if you don't know how to get the data that will be returned.

Woofcat
January 31st, 2001, 09:20
Of course you have to parse the keyword list first... And querying with like on a text description is so inefficient - you'd want a script to go through the pages and pick out keywords, and normalize the database around those...

Daniel Hollands
January 31st, 2001, 11:59
OK, this all look a tiny bit too complex for me at the moment, I think i'll worry about the rest of the site, learn a bit more, and than come back to this.

Thank you for your time, all of you :)