PHPBuilder - Dynamic Document Search Engine - Part 2 Page 5



RSS Twitter
Articles Tricks And Hacks

Dynamic Document Search Engine - Part 2 - Page 5

by: M.Murali Dharan
|
February 25, 2004

Finally we have to display the results in the browser. Here is the code.

<?php
if(isset($FoundRef)) 
{
    echo 
"<table width=\"100%\"><tr><th class=\"title\">Search Result</td></tr></table>";
    echo 
"<br />";
    echo 
sizeof($FoundRef);
    echo (
sizeof($FoundRef) == " reference" " references");
    echo 
" found";
    if(
$junkWords)
    {
        echo 
"Common words like";
        foreach(
$junkWords as $jWords)
        {
            echo 
"&nbsp"."'".$jWords."'";
        }
        echo 
"are removed from the search string";
    }
    echo 
"</h5>";
    foreach(
$FoundRef as $a => $value)
    {
        echo 
"<table>";
        echo 
"<tr><td valign=\"top\">";
        
// echo $FoundRef[$a]["contid"];

        
<a href=showref.php?refid=<?php echo $FoundRef[$a]["contid"]?>><emp><b>
        <?php echo $FoundRef[$a]["title"]?></b></emp></a><div align="right">
        Occurance(s): 
        <?php echo $FoundRef[$a]["occurance"?></div>
        <br /><small>
        <?php echo $FoundRef[$a]["summary"?>...</small>
        <br /><br />
        <?php echo "</td></tr>";
    }
?>

    <?php echo "</table>";
}
//end of isset FoundRef
?>
Timer to Calculate the Time Taken to Search the Documents:
You can include a timer that calculates the time period to do the search operation. Here is the code.

<?php
//START TIMER
$end=getmicrotime();

//PERFORM SEARCH OPERATION

//END TIMER
$end=getmicrotime();

//TOTAL TIME TAKEN TO DO SEARCH OPERATION
$time_taken=(float)($end-$start);
$time_taken=number_format($time_taken,2,'.','');
?>
The following function calculates the time in microseconds.

<?php
function getmicrotime()
{
    list(
$usec,$sec)=explode(" ",microtime());
    return ((float)
$usec+(float)$sec);
}
?>

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
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.