web directoryearn money in seconds   Free file hosting, free video sharing

<<< The Web Hosting >>>


Go Back   Noeman GSM > Webhosting & Website development > Website development > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-13-2007, 05:11 PM
Spiral's Avatar
CO-Admin
 
Join Date: Sep 2004
Location: Martil
Age: 25
Posts: 15,673
Reputation: 18872
Spiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super MemberSpiral Mega Super Member
Default Search Engine like script for mysql

If you are trying to make a script that acts like search engine in your mysql database, here is a simple snipet that you can use to accomplish this task.

This script will work like search engine, first search for the keyword from your database fields which you specify at Match function, after searching the entire search keyword then if the search keyword is more than 1 word the function then split the search term and search for each keyword.

Please take note that this search engine like script will work only if the search term is more than 3 characters and your db is not less than 4 rows.

Here is the code :

PHP Code:
<?
// Standard Connection Data.
$db_host “localhost”;
$db_user “”//YOur database user name
$db_pass “”//your database password
$db_name “”//your datbaase password

$dbs mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($dbs,$db_name) or die (”Cannot connect to database”);

if(!
$_POST[search]){
?>
<Form methos= “POST” action = “#”>
Search For :
<input type=”text” name = “keyword” size=”25″>

<input type=”submit” name=”search” value=”Search”>
</Form>
$sql="Select * from table where MATCH (field1,field2,field3) AGAINST ('%$_POST[keyword]%')";
$rec=mysql_query($sql) or die(mysql_error());
$datas=mysql_fetch_array($rec);

if(mysql_numrows($rec) <1){
echo "No data found from db";
}else{
echo mysql_numrows($rec). " Total search result";
do{
echo "datas[field1] <br>“;
}while($datas=mysql_fetch_array($rec));
}
}

?>
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:23 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 2004-2008 Noeman . All rights reserved
Mobile Phones | Personal Loans | Loan | Loans | Credit Card Consolidation

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111