Help - Search - Members - Calendar
Full Version: Site search
Weborum Webmaster Forum > Web Page Design > PHP
sjthomas
Has anyone got any good tutorials or scripts I can modify for a site search in PHP/mySQL? Basically I'm not advancedc enough to do a search so I'm going to need seome help. Everything is stored in a database with four values that would need to be searched (name, sub-title, keywords and the article itself). Anyone got any tips?

Cheers?
jasonrap
Here is a query that would search for all names that start with "S"

Select name from table_name where name like 'S%'

Is that what you mean?
h198848
I think simply use select would take much system resource
You should use a file cache
aviansuicide
QUOTE(h198848 @ May 23 2005, 08:11 AM)
I think simply use select would take much system resource
  You should use a file cache
[right][snapback]28367[/snapback][/right]


Atchually, files can take up more system resources if they are highly requested -- it depends on what load it takes off of the database as to rather or not it's worth using caches. But you are right in a sense...caching search results is a good idea. Espically if your searching a table with thousands of records -- caching the results of the search(eg: in a 'searches' table)..and only needing to query for the search cache is a big save on usage.

I would suggest using FULLTEXT searching for MySQL...

http://www.mysql.com/doc/en/Fulltext_Search.html
sjthomas
I can't use fulltext searches cause I use innoDB as the engine not MyISAM. I used the like clause with percentage signs and it works ok. The DB isn't huge so the drain on system resources isn't severe enough to offset the "cost" of caching the results. At the moment its very basic search I've got going on so I'm looking to improve it soon.
aviansuicide
Aha...then yeah..you'll want to use LIKE...I've never used InnoDB..so I'm really not sure on the differences. MyISAM has fit me fine.
sjthomas
The main difference is that innoDB has support for relational aspects like constraints etc and I tend to design databases that way so using MyISAM really doesn't do what I want it to. But I didn't realise that until the resident SQL guru told me about it laugh.gif I was trying to figure out why the relational stuff wouldn't work in MyISAM for bloody ages!
aviansuicide
Eh...I tend to do relational things myself..and I've never even looked at InnoDB..but meh.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.