Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
implementing a website search feature using php
Old 07-16-2008, 01:44 PM implementing a website search feature using php
Ultra Talker

Posts: 254
Trades: 0
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.
sudhakararaog is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-16-2008, 02:45 PM Re: implementing a website search feature using php
Skilled Talker

Posts: 77
Name: Bill Benson
Location: Florida
Trades: 0
How many pages do you have? If you are making good use of your heading tags, for example, I'd write something that takes the page title, heading tags, and some of the text following the heading tags and stick it in a db. You could also put the whole page in the db for some sort of advanced search. Searching and finding stuff is what databases are good at.

Could just use the google search function as well, but you would need to put up with their logo.
bill benson is offline
Reply With Quote
View Public Profile
 
Old 07-16-2008, 02:48 PM Re: implementing a website search feature using php
Extreme Talker

Posts: 177
Trades: 0
I would probably do something like...

take the string and remove any special characters from it

then use the explode() function to put all the words (seperated by spaces) into an array

Then I would use those key words to give some search results

Something like this...

PHP Code:

$pattern 
"/^[A-Za-z]/";
$replace "\";
$search preg_replace($pattern$replace$search); 
That should remove all non alpha characters

PHP Code:
$search_array=explode(" "$search); 
$search_array should contain an array with all the words used in the search.

From there, I'm not really to sure what you're trying to do. But hopefully this gets you started, what exactly are you using to compare the search strings with?
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 07-16-2008, 11:42 PM Re: implementing a website search feature using php
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Doing a search function like this based off files is very CPU laboring and ineffiecient. You would much better luck converting all your site content from a database.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-17-2008, 09:06 PM Re: implementing a website search feature using php
Junior Talker

Posts: 2
Trades: 0
http://sphider.eu/ is a very good php search engine. You would need a database however to use it..
chadsmith76 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to implementing a website search feature using php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27958 seconds with 12 queries