Question : HTML & MySQL -  How "Search" process runs ?

Mr. Experts,

Thank you for all your valuable advices.
I have a dumb question and please forgive me. I am a slow learner.
I saw "SEARCH" features on many websites, such as Searching for products, people, books tec...

My small knowledge about these Search process is to find the item by MySQL in databse
by using SQL statement "SELECT" with "WHERE", "AND", "OR", etc......
I only know this way to create a Search feature on websites.


If there any other ways that perform "SEARCH" action in the database or in file or in folders...?
Is there any online tutorials about how search process works ?
I want to learn everything about SEARCH process....

Please advise.... Thank you.

Search proceess is initiated from a form on the webpage ( sample as below)


<form class="Find_Item" method="get" action="/search/product" name="Search_Product">

       <input type="text" id="item_searched" autocomplete="off" class="item_search" name="item_keywords"   value="" size="50" title="Search Item"  />  
        <input type="image" src=http://get.images-sales.com/images/Go.gif    alt="Go" />
         
</form>











Answer : HTML & MySQL -  How "Search" process runs ?

Here's the quick script to get all files from the directory:

<?php
if ($handle = opendir($directory_name)) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            $out[] = $file;
        }
    }
    closedir($handle);
}
?>

Replace $directory_name with the path to the folder you want to search within.
After this code has been executed you will have array called $out which will store all files within the provided directory.

What you can do now - once you've submitted the search form with the value is:

if (isset($_GET['keyword'])) {

$keyword = $_GET['keyword'];

if (!empty($out) && in_array($keyword, $out)) {
echo "File has been found";
} else {
echo "File has not been found";
}

}

I hope this helps
Random Solutions  
 
programming4us programming4us