Zeronese, Inc.
Home
Help & Support
Contact Us
Website Templates Web Hosting Reseller Hosting Web Design Web Directory Article Directory Webmaster Tools Make Money Marketing SEO
  economic web hosting Browse Webmasters Article Directory  
 


Log in - Submit Your Article Here

Browse Article Directory

Advice and Reviews Articles Advice and Reviews
Domain Names Articles Domain Names
ecommerce Articles ecommerce
HTML and CSS Articles HTML and CSS
Internet Search Engines Related Articles Internet Search Engines Related
Make Money Online Articles Make Money Online
Other Web Subjects Articles Other Web Subjects
Web Design Articles Web Design
Web Design Software Articles Web Design Software
Web Development Articles Web Development
Web Hosting Articles Web Hosting
web publishing content Articles web publishing content
Website Marketing Articles Website Marketing
web content article categories View all Categories

Article Directory News Letter

 


 
     

 


  By: Rory Canyon  
 

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:





Web Search







































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.



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.



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.



Now, combine the programs listed above, you will find all the related results in your websites will be found and listed. A further optimization of the search engine can be taken 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("(.+)

",$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 " $filedir "."\n";

}

3 Set time limit for PHP execution

ADD THE FOLLOWING AT THE BEGINNING OF PHP FILES

set_time_limit("600");

The above unit is second,so ten minutes is the litmit.

Now, combine all the above programs and get the complete search.php file as following,



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

About The Author


Rory Canyon is the founder of ScriptMenu.com, a free web directory for PHP, ASP, ASP.NET, PERL, XML, Java, JavaScript, Flash, CFML, Python and other web programming resources.

For more information, visit http://www.scriptmenu.com

Article Source: zeronese.net article directory.
Article Word Count Appx. : 550
Article Category: Articles » Web-Development » PHP
See all articles by Rory Canyon


Note: Copying of article contents in whole is permitted provided that article body and article author by-lines are kept intact and unchanged. Hyperlinks and/or URLs including article source link provided by authors and/or zeronese must remain active at all times.

     
The views and opinions of authors expressed on Zeronese Article Directory web sites do not necessarily state or reflect those of the Zeronese.net .


Feedback News Letter Site Map Terms and Policies About Us All copyrights reserved 2008 Zeronese, Inc.©