PHPBuilder - Dynamic Document Search Engine - Part 1 Page 3



RSS Twitter
Articles Tricks And Hacks

Dynamic Document Search Engine - Part 1 - Page 3

by: M.Murali Dharan
|
February 17, 2004

The code snippet given below explains every step of the program.
Searching keyword table for every word is a long process. This also reduces the efficiency of the program. To implement this all the keywords in the keyword table is stored in an associative array $allWords. An associative array is one, which works on B-Tree algorithm and very useful to perform searches. Here is the function.

<?php
Function LoadCurrentWords(){
global 
$allWords;

    
$result mysql_query"select keyid, keyword from keytable" ) or die( "Error in executing mysql query" );

    while ( 
$row mysql_fetch_array($result) ) {
        
$allWords[$row[‘keyword’] = $row[‘keyid’];
    }
}
?>

Common Words:

$COMMON_WORDS is an associative array that stores an array of words, which are commonly used in English Language. These words have to be removed while parsing the file.
$COMMON_WORDS=array(“a”=>1, “as”=>1);
You can add as many common words as you like. See source code for full list of common words.

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
M.Murali Dharan

Comment:



Comment:

(Maximum characters: 1200). You have characters left.