Bluehost.com Web Hosting $6.95

implementing a website search feature using php

This is a discussion on implementing a website search feature using php within the PHP General forums, part of the PHP Programming Forums category; i want to implement a feature where a user searches with a keyword and search results are displayed according to ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-16-2008
Sudhakar
 
Posts: n/a
Default implementing a website search feature using php

i want to implement a feature where a user searches with a keyword and
search results are displayed according to the keyword

or phrase entered by the user.

following are the steps i want to follow. please advice if i am missing out
any steps or i can add any step.

1. read the keyword entered by user using $search = $_POST["searchkeyword"];

2. read all the files from the root directory into a variable (as all files
will be saved in the root directory)

3. from step 2 filter and read only files with html and php extensions into
a variable

4. read the entire contents of all html and php files into a variable

5. compare $search with all the individual html and php file contents from
step 4

6. if a match is found with either html or php file then display a brief
title and brief description which will be a link to

the actual file which has the keyword.

7. display search results in a serial order as 1. Brief Title of the page 2.
Brief Title of the page ...

8. at the bottom of the page based on the total number of results found from
step 6 i would like to provide a link to page 1
page 2 page3 ... (i can decide to display only 10 results per page)

please advice.

any help will be greatly appreciated.

thanks.

Reply With Quote
  #2 (permalink)  
Old 07-16-2008
Robert Cummings
 
Posts: n/a
Default Re: [PHP] implementing a website search feature using php

On Wed, 2008-07-16 at 22:50 +0530, Sudhakar wrote:
> i want to implement a feature where a user searches with a keyword and
> search results are displayed according to the keyword
>
> or phrase entered by the user.
>
> following are the steps i want to follow. please advice if i am missing out
> any steps or i can add any step.
>
> 1. read the keyword entered by user using $search = $_POST["searchkeyword"];
>
> 2. read all the files from the root directory into a variable (as all files
> will be saved in the root directory)
>
> 3. from step 2 filter and read only files with html and php extensions into
> a variable
>
> 4. read the entire contents of all html and php files into a variable
>
> 5. compare $search with all the individual html and php file contents from
> step 4
>
> 6. if a match is found with either html or php file then display a brief
> title and brief description which will be a link to
>
> the actual file which has the keyword.
>
> 7. display search results in a serial order as 1. Brief Title of the page 2.
> Brief Title of the page ...
>
> 8. at the bottom of the page based on the total number of results found from
> step 6 i would like to provide a link to page 1
> page 2 page3 ... (i can decide to display only 10 results per page)


Either use something like htdig or Lucene or run a cron that crawls your
files as you indicate above and caches the content to a MySQL (or other
db server) FULLTEXT column. Then query/search accordingly. You can feel
free to re-invent this particular wheel... but you'll probably spend a
lot of time doing it wrong.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

Reply With Quote
  #3 (permalink)  
Old 07-16-2008
tedd
 
Posts: n/a
Default Re: [PHP] implementing a website search feature using php

At 10:50 PM +0530 7/16/08, Sudhakar wrote:
>i want to implement a feature where a user searches with a keyword and
>search results are displayed according to the keyword


-snip-

It sounds like you want a search for a site -- if so, see this:

http://sperling.com/examples/search/

It's a lot less work.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
Reply With Quote
  #4 (permalink)  
Old 07-16-2008
Eric Butera
 
Posts: n/a
Default Re: [PHP] implementing a website search feature using php

On Wed, Jul 16, 2008 at 1:20 PM, Sudhakar <sudhakararaog@gmail.com> wrote:
> i want to implement a feature where a user searches with a keyword and
> search results are displayed according to the keyword
>
> or phrase entered by the user.
>
> following are the steps i want to follow. please advice if i am missing out
> any steps or i can add any step.
>
> 1. read the keyword entered by user using $search = $_POST["searchkeyword"];
>
> 2. read all the files from the root directory into a variable (as all files
> will be saved in the root directory)
>
> 3. from step 2 filter and read only files with html and php extensions into
> a variable
>
> 4. read the entire contents of all html and php files into a variable
>
> 5. compare $search with all the individual html and php file contents from
> step 4
>
> 6. if a match is found with either html or php file then display a brief
> title and brief description which will be a link to
>
> the actual file which has the keyword.
>
> 7. display search results in a serial order as 1. Brief Title of the page 2.
> Brief Title of the page ...
>
> 8. at the bottom of the page based on the total number of results found from
> step 6 i would like to provide a link to page 1
> page 2 page3 ... (i can decide to display only 10 results per page)
>
> please advice.
>
> any help will be greatly appreciated.
>
> thanks.
>


Zend Search Lucene is pretty nice.

http://framework.zend.com/manual/en/...ch.lucene.html
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:44 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0