|
||||||||||
|
|||||||
| GoogleCommunity Sponsor |
Use coupon "forum" for 50% Off! |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Noogle
![]() Join Date: Apr 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Make search engine With PHP and mySQL, for your site
Learn how to make a search engine using the power of PHP and mySQL.
Here is an useful script that anyone can use to search a mySQL database and spit out the results as you want them. They have to be broken down into two separate files. One is an HTML form with action leading to the script PHP file. Lets work on the form first because it is the easiest. Here is what we have to write in English for the Form: Dec Insert the values into the correct database. Get a conformation that it has been uploaded Here it is in PHP: Search: <form method="post" action="search.php"> <input type="text" name="search" size=25 maxlength=25> <input type="Submit" name="Submit" value="Submit"> </form> And that is basically all the code we have to write for the form. Now the hard part, writing the processing, which isn't really as hard as it seems. Here is what we have to write in English for the Processing: Connect to the server and select the right database. Grab the result, as you can see, its a fairly obvious line of code. Run a while loop running the results we got. Define each result a variable and spit it out. Else say "Nothing Found" Here it is in PHP: <? //connect to server mysql_pconnect("server","server","password"); //select the db mysql_select_db("database"); //get the results and store them in $result $result = mysql_query ("SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search%'"); //run the while loop while($r=mysql_fetch_array($result)) { //grab the result $whatevercolumn=$r["whatevercolumn"]; //print it out echo $whatevercolumn; echo " "; } //else nothing is found else { echo "Nothing found"; } ?> Couple of things: You have to rename the the name and password for the connection to the mySQL. You have to change the database name. Also change the whatevertable and whatevercolumn to the right table and column you want to search from. That's about it! |
|
|
|
|
Sponsored Links
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Site Down Time Can Remove You From Google Index - Search Engine Roundtable | News Alerts | Google in the News | 0 | 02-19-2007 05:33 AM |
| Dif. between search engine optimization and search engine positioning | Dejavu | Search Engine Optimization Forum | 7 | 02-14-2007 02:58 AM |
| Google Video Search Now Include YouTube Results - Search Engine Land | News Alerts | Google in the News | 0 | 01-25-2007 07:02 AM |
| I need a PHP with mysql site | jetbrains | Web Hosting Forum | 9 | 09-27-2006 07:51 AM |
| Can't index our site on google search engine | trramatper | All About Google | 2 | 06-09-2006 11:43 PM |