Jump to content


Photo

Keyword search


  • Please log in to reply
6 replies to this topic

#1 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 15 October 2006 - 06:29 AM

How to create a keywords search which can search 1 in the title, 2 in the description.

Please help,desperately need a solution.  :-\

#2 dymon

dymon
  • Members
  • PipPipPip
  • Advanced Member
  • 79 posts

Posted 15 October 2006 - 07:22 AM

Provide please more details about the search.
Web is the future ... desktop will die ...

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 15 October 2006 - 10:25 AM

SELECT * FROM tablename
WHERE (title LIKE '%$keyword%')
OR (description LIKE '%$keyword%')
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 15 October 2006 - 10:45 AM

To do Google-like searching ("bla3 bla1" -bla2 +bla3) you may use fulltext searching:
SELECT * FROM tablename WHERE MATCH (title,body) AGAINST ('"bla3 bla1" -bla2 +bla3' IN BOOLEAN MODE);


#5 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 18 October 2006 - 04:13 PM

Bernard are you sure that SELECT * FROM tablename
WHERE (title LIKE '%$keyword%')
OR (description LIKE '%$keyword%') will find exactly the matches...because i dont want unneeded results.

#6 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 18 October 2006 - 04:46 PM

To find exact matches, remove the percentage signs:

<?php

SELECT * FROM tablename WHERE (title LIKE '$keyword') OR (description LIKE '$keyword') // exact match

SELECT * FROM tablename WHERE (title LIKE '%$keyword%') OR (description LIKE '%$keyword%') // match somewhere in

SELECT * FROM tablename WHERE (title LIKE '$keyword%') OR (description LIKE '$keyword%') // exact match on "starting with"

SELECT * FROM tablename WHERE (title LIKE '%$keyword') OR (description LIKE '%$keyword') // exact match on "ending with"

?>



#7 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 18 October 2006 - 06:09 PM

Thanks





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users