Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Search script problem


PHP Search script problem

Reply
  #1 (permalink)  
Old 11-22-03, 06:35 AM
vispa vispa is offline
New Member
 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Search script problem

Hiya,

I am currently working on a new search script for a new FAQ section of my web site, but it don't quite seem to be as clever as I would like.

I have some test data in MySQL (v3.23), and one of the fields is title. In this title is "Connecting with Windows XP" and another is "Connecting with Windows 98".

I am trying to make use of MySQL FULLTEXT, and I currently have the following Db Structure

Code:
CREATE TABLE topics ( 
  id tinyint(4) NOT NULL auto_increment, 
  title varchar(100) NOT NULL default '', 
  description text NOT NULL, 
  details text NOT NULL, 
  keywords text NOT NULL, 
  type varchar(50) NOT NULL default '', 
  category varchar(50) NOT NULL default '', 
  created_by varchar(25) NOT NULL default '', 
  created_date date default NULL, 
  edited_date date default NULL, 
  PRIMARY KEY  (id), 
  FULLTEXT KEY title (title,description,keywords) 
) TYPE=MyISAM;
The code I am currently using to search in MySQL is

Code:
$query1 = "SELECT * FROM topics WHERE MATCH (title,description,keywords) AGAINST ('$term')";
However while the above seems to work it requires me to give a very big search term to find just 1 match. For instance if I give a search term of "Windows XP" it find nothing, and likewise "Windows" or "Connecting" finds nowt, but then "Connecting with Microsoft Windows XP" will start to show results.

The object of the code is to search titles, descriptions and keywords then rank based on what nearest.

How on earth can I make this bit more intelligent without going totally overboard? Maybe FULLTEXT is wrong method (though this naturally ranks right)? Where am I stuffing up?

Cheers guys!

Martin
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-22-03, 01:22 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Try something like this...

$query1 = "SELECT * FROM topics WHERE title LIKE '$term' AND description LIKE '$term' AND keywords LIKE '$term'";

See if that does any better. You can also try with " % " to see what happens, i.e.

'%$term'
'%$term%'

Different variations may give you different results.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SEO Expert Available nakulgoyal Job Offers & Assistance 2 08-14-04 01:38 PM
How to integrate a search engine to my script ? Simonoff Script Requests 2 10-31-03 04:43 PM
PHP script required Mickey Job Offers & Assistance 8 09-07-03 04:00 PM
I need help with my first php script NeverMind PHP 4 08-01-03 02:27 PM
30% off Hosting - Free PHP Script Autoinstaller cyberwisdom General Advertisements 0 07-06-03 02:47 PM


All times are GMT -5. The time now is 12:53 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.