Member You
#1 in Business Subscribe Email Print

You are here: Home > Internet and Businesses Online > Web Development > Design a Search Engine for Your Own Site with PHP

Tags

  • value
  • price
  • different
  • following scripts
  • functionlistfilesphparrayechoprint search
  • website search

  • Links

  • Myrtle Beach Golf Vacations Can Provide Exactly What You Are Looking For
  • Marketing and Sales in A Presentation
  • Discover Unique Wine Racks
  • Member You - Design a Search Engine for Your Own Site with PHP

    Domain Names: How To Claim Your Piece of Virtual Real Estate
    A domain name is an important factor in creating a web presence. Your domain is a very important decision you make with regards to building a website. It will make your website unique and make it easier to be found online.There are a few considerations to keep in mind should you choose to purchase a domain name. You want to make your domain relate to your product if at all possible. There are several extensions that you can use to complete the name of your domain. I’m going to suggest that you stick with the .com extension even though they are several to choose from.People are used to typing in dot com. You don’t want to try to have to retrain the way people are used to thinking. Dot com is already established and as
    ckquote>

    set_time_limit("600");

    $keyword=trim($_POST["keyword"]);

    if($keyword==""){

    echo"Please enter your keyword";

    exit; }

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    if(eregi("]+)>(.+)",$data,$b)){

    $body=strip_tags($b["2"]);

    }

    else{

    $body=strip_tags($data);

    }

    if($file!="search.php"){

    if(eregi("$keyword",$body)){

    if(eregi("(.+)",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    }

    }

    }

    }

    }

    $array=array();

    listFiles(".","$keyword",$array);

    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir target=_blank>$title</a>"."<br>"; } ?>

    Now, you have made a search

    Financing Your Small Business
    One of the comments I hear most often from my clients is that they are struggling to make a living with their business. They're very often in a position where they are in dire need of getting clients or making sales just to pay the bills.And when you're just getting your business off the ground this is to be expected.Because it takes time to get your business up and running and to market and to become known.It's not usually something that happens overnight.Every time I've launched a new business, I've taken steps to ensure I don't end up in this dire situation. Because there is nothing more stressful than wondering if you're going to be able to pay your bills.Or feeling like if you don't start
    This hands on PHP Programming article provides the knowledge necessary to design and develop a search engine for your website using PHP version 4.0 and above. Making a search engine for your website with PHP is really easy and provides substantial functionality required by most of the small to medium websites. This article introduces every steps of the development, including both design and PHP programming. Basic computer skills and knowledge of HTML fundamentals are required. Ok, let's begin now.

    Step 1: Design Search Box

    Under your website root, make a file called search.htm or anything you like and type in the following code:

    <html>

    <head>

    <title>Web Search</title>

    <meta http-equiv="Content-Type" content="text/html">

    </head>

    <body bgcolor="#FFFFFF" text="#000000">

    <form name="form1" method="post" action="search.php">

    <table width="100%" cellspacing="0" cellpadding="0">

    <tr>

    <td width="36%">

    <div align="center">

    <input type="text" name="keyword">

    </div>

    </td>

    <td width="64%">

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

    </td>

    </tr>

    </table>

    </form>

    </body>

    </html>

    Step 2: Write search.php file. It is the core of your website search engine.

    Under your website root, create a file called search.php or anything you like.

    //get keywords

    $keyword=trim($_POST["keyword"]);

    //check if the keyword is empty

    if($keyword==""){

    echo"no keywords";

    exit;

    }

    ?>

    With above, you can give hints to your users when they forget to enter a keyword. Now let's go through all the files or articles in your website.

    function listFiles($dir){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    //if it is a directory, then continue

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file");

    }

    else{

    //process the searching here with the following PHP script

    }

    }

    }

    }

    ?>

    The following scripts read, process files and check whether the files contain $keyword. If $keyword is found in the file, the file address will be saved in an array-type variable.

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    //read file

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    //avoid search search.php itself

    if($file!="search.php"){

    //contain keyword?

    if(eregi("$keyword",$data)){

    $array[]="$dir/$file";

    }

    }

    }

    }

    }

    }

    //define array $array

    $array=array();

    //execute function

    listFiles(".","php",$array);

    //echo/print search results

    foreach($array as $value){

    echo "$value"."
    n";

    } ?>

    Now, combine the codes listed above, all the related results in your websites will be found and listed.

    Step 3: further improvement of the search engine can be made by adding the following,

    (1) list the title of all searching results

    REPLACE THE FOLLOWING

    if(eregi("$keyword",$data)){

    $array[]="$dir/$file";

    }

    WITH

    if(eregi("$keyword",$data)){

    if(eregi("(.+)</p><p>",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    (2) Add links to searching results

    CHANGE THE FOLLOWING

    foreach($array as $value){

    echo "$value"."
    n";

    }

    TO
    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir>$value</a>"."<br>";

    }

    (3) Set time limit for PHP execution

    ADD THE FOLLOWING AT THE BEGINNING OF PHP FILES

    set_time_limit("600");
    The above time unit is second. 10 minutes is the script execution litmit.

    Combine all the above codes and get the complete search.php file as following,

    set_time_limit("600");

    $keyword=trim($_POST["keyword"]);

    if($keyword==""){

    echo"Please enter your keyword";

    exit; }

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    if(eregi("]+)>(.+)",$data,$b)){

    $body=strip_tags($b["2"]);

    }

    else{

    $body=strip_tags($data);

    }

    if($file!="search.php"){

    if(eregi("$keyword",$body)){

    if(eregi("(.+)",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    }

    }

    }

    }

    }

    $array=array();

    listFiles(".","$keyword",$array);

    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir target=_blank>$title</a>"."<br>"; } ?>

    Now, you have made a search

    The Adsense Adwords Google Secret That Can Make You Rich
    In 2000 Google launched their advertising platform and from it’s very inception it was a resounding success. Today, Google’s advertising network is the biggest in the world and Google’s main form of revenue. You only have to take a quick glimpse at Google’s share price to see just how successful Adwords and Adsense really is. Although Google are making a lot of money from this, they are providing an amazing opportunity for virtually anyone to advertise on a shoestring budget and reach an audience that was previously virtually inaccessible.It wasn’t long before creative entrepreneurs and internet marketers got their claws into some of the Adsense Adwords Google secrets and started cashing in with various strategies. Ever since Goo
    >

    </div>

    </td>

    <td width="64%">

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

    </td>

    </tr>

    </table>

    </form>

    </body>

    </html>

    Step 2: Write search.php file. It is the core of your website search engine.

    Under your website root, create a file called search.php or anything you like.

    //get keywords

    $keyword=trim($_POST["keyword"]);

    //check if the keyword is empty

    if($keyword==""){

    echo"no keywords";

    exit;

    }

    ?>

    With above, you can give hints to your users when they forget to enter a keyword. Now let's go through all the files or articles in your website.

    function listFiles($dir){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    //if it is a directory, then continue

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file");

    }

    else{

    //process the searching here with the following PHP script

    }

    }

    }

    }

    ?>

    The following scripts read, process files and check whether the files contain $keyword. If $keyword is found in the file, the file address will be saved in an array-type variable.

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    //read file

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    //avoid search search.php itself

    if($file!="search.php"){

    //contain keyword?

    if(eregi("$keyword",$data)){

    $array[]="$dir/$file";

    }

    }

    }

    }

    }

    }

    //define array $array

    $array=array();

    //execute function

    listFiles(".","php",$array);

    //echo/print search results

    foreach($array as $value){

    echo "$value"."
    n";

    } ?>

    Now, combine the codes listed above, all the related results in your websites will be found and listed.

    Step 3: further improvement of the search engine can be made by adding the following,

    (1) list the title of all searching results

    REPLACE THE FOLLOWING

    if(eregi("$keyword",$data)){

    $array[]="$dir/$file";

    }

    WITH

    if(eregi("$keyword",$data)){

    if(eregi("(.+)</p><p>",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    (2) Add links to searching results

    CHANGE THE FOLLOWING

    foreach($array as $value){

    echo "$value"."
    n";

    }

    TO
    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir>$value</a>"."<br>";

    }

    (3) Set time limit for PHP execution

    ADD THE FOLLOWING AT THE BEGINNING OF PHP FILES

    set_time_limit("600");
    The above time unit is second. 10 minutes is the script execution litmit.

    Combine all the above codes and get the complete search.php file as following,

    set_time_limit("600");

    $keyword=trim($_POST["keyword"]);

    if($keyword==""){

    echo"Please enter your keyword";

    exit; }

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    if(eregi("]+)>(.+)",$data,$b)){

    $body=strip_tags($b["2"]);

    }

    else{

    $body=strip_tags($data);

    }

    if($file!="search.php"){

    if(eregi("$keyword",$body)){

    if(eregi("(.+)",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    }

    }

    }

    }

    }

    $array=array();

    listFiles(".","$keyword",$array);

    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir target=_blank>$title</a>"."<br>"; } ?>

    Now, you have made a search

    Reverse Auction Success Hinges on Pre-Qualfying Vendors
    The first reason is that if you try to do a post-reverse auction qualification, to the bidders, that gives them the impression that price really doesn’t matter. So why should they bid lower in the reverse auction if they believe their quality alone will win them the business? Well, the Buyer's job is to pre-qualify bidders so they know that they are competing against like-quality vendors and price will absolutely matter during the reverse auction. A simple way to do this is to create a survey with qualifying questions. Examples of these types of questions are how long the company has been in business, how many employees they have and if they have a proper level of insurance. This will automatically give the vendors the impression that y
    e following PHP script

    }

    }

    }

    }

    ?> The following scripts read, process files and check whether the files contain $keyword. If $keyword is found in the file, the file address will be saved in an array-type variable.

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    //read file

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    //avoid search search.php itself

    if($file!="search.php"){

    //contain keyword?

    if(eregi("$keyword",$data)){

    $array[]="$dir/$file";

    }

    }

    }

    }

    }

    }

    //define array $array

    $array=array();

    //execute function

    listFiles(".","php",$array);

    //echo/print search results

    foreach($array as $value){

    echo "$value"."
    n";

    } ?>

    Now, combine the codes listed above, all the related results in your websites will be found and listed.

    Step 3: further improvement of the search engine can be made by adding the following,

    (1) list the title of all searching results

    REPLACE THE FOLLOWING

    if(eregi("$keyword",$data)){

    $array[]="$dir/$file";

    }

    WITH

    if(eregi("$keyword",$data)){

    if(eregi("(.+)</p><p>",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    (2) Add links to searching results

    CHANGE THE FOLLOWING

    foreach($array as $value){

    echo "$value"."
    n";

    }

    TO
    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir>$value</a>"."<br>";

    }

    (3) Set time limit for PHP execution

    ADD THE FOLLOWING AT THE BEGINNING OF PHP FILES

    set_time_limit("600");
    The above time unit is second. 10 minutes is the script execution litmit.

    Combine all the above codes and get the complete search.php file as following,

    set_time_limit("600");

    $keyword=trim($_POST["keyword"]);

    if($keyword==""){

    echo"Please enter your keyword";

    exit; }

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    if(eregi("]+)>(.+)",$data,$b)){

    $body=strip_tags($b["2"]);

    }

    else{

    $body=strip_tags($data);

    }

    if($file!="search.php"){

    if(eregi("$keyword",$body)){

    if(eregi("(.+)",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    }

    }

    }

    }

    }

    $array=array();

    listFiles(".","$keyword",$array);

    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir target=_blank>$title</a>"."<br>"; } ?>

    Now, you have made a search

    Extra-Ordinary Prospecting - Be Memorable and Reward Yourself
    When it comes to effective prospecting, Being a warm voice on the end of the phone, who sounds different to the majority out there is paramount and hopefully memorable.Ok your warm but don't get cuddly. You don't want to sound creepy and wet. No one likes creepy.Of course nice and friendly doesn't work on everyone. You have to be relatable with whoever you talk to. Sometimes people want the facts with no small talk. Be clear, concise and direct. If you feel you are not getting anywhere, call back another time. The person may be having a hard day. You may get a better response another time from them or someone else may answer who is more receptable.You have to use different techniques for different people. When peopl
    further improvement of the search engine can be made by adding the following,

    (1) list the title of all searching results

    REPLACE THE FOLLOWING

    if(eregi("$keyword",$data)){

    $array[]="$dir/$file";

    }

    WITH

    if(eregi("$keyword",$data)){

    if(eregi("(.+)</p><p>",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    (2) Add links to searching results

    CHANGE THE FOLLOWING

    foreach($array as $value){

    echo "$value"."
    n";

    }

    TO
    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir>$value</a>"."<br>";

    }

    (3) Set time limit for PHP execution

    ADD THE FOLLOWING AT THE BEGINNING OF PHP FILES

    set_time_limit("600");
    The above time unit is second. 10 minutes is the script execution litmit.

    Combine all the above codes and get the complete search.php file as following,

    set_time_limit("600");

    $keyword=trim($_POST["keyword"]);

    if($keyword==""){

    echo"Please enter your keyword";

    exit; }

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    if(eregi("]+)>(.+)",$data,$b)){

    $body=strip_tags($b["2"]);

    }

    else{

    $body=strip_tags($data);

    }

    if($file!="search.php"){

    if(eregi("$keyword",$body)){

    if(eregi("(.+)",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    }

    }

    }

    }

    }

    $array=array();

    listFiles(".","$keyword",$array);

    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir target=_blank>$title</a>"."<br>"; } ?>

    Now, you have made a search

    Training For New Commercial Real Estate Professionals
    Every commercial real estate brokerage firm claims to have great training, but few really do. Our research indicates that the quality of the training programs in the industry varies significantly. Thus, those seeking to enter the highly competitive commercial real estate field should do some research and assess the real training capabilities of their prospective employer to increase their chances of success.The most prevalent training methods today consist of spending time as a researcher or marketing assistant, or as a “runner” for a more experienced broker. In some cases, an office manager may assemble new employees together for informal “training” sessions once a month. Most often, the new employee learns the business through
    ckquote>

    set_time_limit("600");

    $keyword=trim($_POST["keyword"]);

    if($keyword==""){

    echo"Please enter your keyword";

    exit; }

    function listFiles($dir,$keyword,&$array){

    $handle=opendir($dir);

    while(false!==($file=readdir($handle))){

    if($file!="."&&$file!=".."){

    if(is_dir("$dir/$file")){

    listFiles("$dir/$file",$keyword,$array);

    }

    else{

    $data=fread(fopen("$dir/$file","r"),filesize("$dir/$file"));

    if(eregi("]+)>(.+)",$data,$b)){

    $body=strip_tags($b["2"]);

    }

    else{

    $body=strip_tags($data);

    }

    if($file!="search.php"){

    if(eregi("$keyword",$body)){

    if(eregi("(.+)",$data,$m)){

    $title=$m["1"];

    }

    else{

    $title="no title";

    }

    $array[]="$dir/$file $title";

    }

    }

    }

    }

    }

    }

    $array=array();

    listFiles(".","$keyword",$array);

    foreach($array as $value){

    list($filedir,$title)=split("[ ]",$value,"2");

    echo "<a href=$filedir target=_blank>$title</a>"."<br>"; } ?>

    Now, you have made a search engine for your website, enjoy it!

    HTTP = HTML link (for blogs, profiles,phorums):
    <a href="http://www.memberyou.net/article/87313/memberyou-Design-a-Search-Engine-for-Your-Own-Site-with-PHP.html">Design a Search Engine for Your Own Site with PHP</a>

    BB link (for phorums):
    [url=http://www.memberyou.net/article/87313/memberyou-Design-a-Search-Engine-for-Your-Own-Site-with-PHP.html]Design a Search Engine for Your Own Site with PHP[/url]

    Related Articles:

    What Can Influence Success Online?

    Web Directories

    See Your Hotmail and Myspace Accounts From the Office

    Bookmark it: del.icio.us digg.com reddit.com netvouz.com google.com yahoo.com technorati.com furl.net bloglines.com socialdust.com ma.gnolia.com newsvine.com slashdot.org simpy.com shadows.com blinklist.com