Current location: Hot Scripts Forums » Programming Languages » PHP » Search Script


Search Script

Reply
  #1 (permalink)  
Old 03-31-04, 11:21 AM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
Search Script

I my DB i have a table called books and I want a search it for keywords.

If a user puts in a word I want php to seacrh the columns 'title' and 'comments' for that word, then give me a percentage for each result

Is there anyone free ones out there or can someone give me the code on how to do it.

Cheers
Reply With Quote
  #2 (permalink)  
Old 03-31-04, 12:16 PM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
use LIKE in your SQL query to do this..
PHP Code:

//assuming this is the keyword..

$term trim($_POST['term']);

$fetch mysql_query("SELECT * FROM books WHERE title LIKE '%$term%' OR comments LIKE '%$term%'")or
die(
mysql_error());

//complete the process here.. 
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 03-31-04, 01:42 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by NeverMind
use LIKE in your SQL query to do this..
PHP Code:

//assuming this is the keyword..

$term trim($_POST['term']);

$fetch mysql_query("SELECT * FROM books WHERE title LIKE '%$term%' OR comments LIKE '%$term%'")or
die(
mysql_error());

//complete the process here.. 

So how do I get a percentage score for each result ?
Reply With Quote
  #4 (permalink)  
Old 04-01-04, 02:46 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Quote:
So how do I get a percentage score for each result ?
don't know what exactly you mean by that !
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #5 (permalink)  
Old 04-02-04, 01:43 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
well, on some sites you can get maby 10 results, and get a percentage of which was closest to your query.
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
cross language search script cgiwizard Script Requests 0 03-09-04 06:43 PM
Simple search script niceguyonline Script Requests 3 03-07-04 11:09 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM
How to integrate a search engine to my script ? Simonoff Script Requests 2 10-31-03 03:43 PM


All times are GMT -5. The time now is 10:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.