PHPBuilder - Dynamic Document Search Engine - Part 1 Page 6



RSS Twitter
Articles Tricks And Hacks

Dynamic Document Search Engine - Part 1 - Page 6

by: M.Murali Dharan
|
February 17, 2004

Process Form function():

This is the core part of the upload program. After finishing filtering, removing common words and duplicate words, this function is called. First this function inserts the title and abstract in the content table. The newly generated content id stored in $contentId. Then it updates keyword and link table.
For every word in the $wordMap array, if the word is already exists in keyword table, it inserts the key id, content id in to link table. Conversely, if the word is not found, it inserts the new word in keyword table, the generated new key id is stored in $keyId. Then it updates link table by inserting key id content id in link table.

<?php
function ProcessForm($title ,$body){

global   
$allWords;

$tempWordList ExtractWords$body );
$wordList FilterCommonAndDuplicateWords($tempWordList);

// insert into content
mysql_querysprintf"INSERT INTO content (title, abstract) VALUES ('%s', '%s')",
mysql_escape_string($title), mysql_escape_string($body) ) );

//store the newly generated content id in $contentId
$contentId mysql_insert_id();

    
// insert all the new words and links
    
while(list($word,$val)=each($wordList)) {
        
$keyId "";
        if ( !
$allWords[$word] ) {
            
mysql_querysprintf"INSERT INTO keytable ( keyword ) VALUES ( '%s' )",
                
mysql_escape_string($word) ) );

            
$keyId mysql_insert_id();
            
$allWords[$word] = $keyId;
        }
        else {
            
$keyId $allWords[$word];
        }

        
// insert the link
        
mysql_querysprintf"INSERT INTO link (keyid, contid) VALUES ( %d, %d )"$keyId$contentId ) );
    }
//End of Processing Form.

}
?>

« 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.