#native_company# #native_desc#
#native_cta#

Dynamic Document Search Engine – Part 1 Page 12

By M.Murali Dharan
on February 17, 2004

The HTML page to get input from user is given below.

<html>

<head>

<title>Search Engine</title>

<style type="text/css">

body{    font-size:20;    font-weight:bold; font-stretch:semi-expand; font-family:MSserif;    color:#0066CC;    

background-color:#EEEEE4;

align:center; background-color:white    }

h4{      background-color:#0066CC;     color:#FFFFFF;   font-family:verdana;  }

h3{  color:#0066CC;   }

th{  background-color:#6996ED;  color:#FFFFFF;  font-family:Arial;   }

a{text-decoration:none;}

</style>

</head>

<body>

<?php

if($submit)

{

    if(!
$keywords){

        
$errmsg="Sorry, Please fill in search field";

        
form($errmsg);

    }else{

           
//Start Timer

            
$start getmicrotime();

          //PERFORM SEARCH OPERATION AND DISPLAY RESULT

        
}else {

            
//end Timer

            
$end getmicrotime();

            //TOTAL TIME TAKEN TO DO SEARCH OPERATION

            
$time_taken=(float)($end-$start);

            
$time_taken=number_format($time_taken,2,'.','');

            echo "<p>Your Query Executed in $time_taken Seconds";

            $errmsg="<p>No Search result found for '$keywords'";

            echo 
$errmsg;

            echo 
"<br /><a href="#" onclick="history.back()">Back</a>";

        }
//endof isset ref

    
}//end of if key word exists

} else {  //display the form

    
form($keyword);

//END OF FORM DISPLAY ?>

</body>

</html>

    <?php

function form($errmsg)

{  
?>

    <h4 align="center">Search Engine</h4>

        <b><?php echo $errmsg?></b>

        <form method=POST action=<?php echo $PHP_SELF ?>>

        Enter keywords to search on:

        <input type="text" name="keywords" maxlength="100" />

        <input type="submit" name="submit" value="Search" />

        </form>

        </body>

        </html>

        <?php

}

function getmicrotime()

{

    list(
$usec,$sec)=explode(" ",microtime());

    return ((float)
$usec+(float)$sec);

}

?>



Function getmicrotime() returns time in microseconds. This function is called during start and
end of the search process.

1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
|
|
12
|