Re: About Website Search Engine
| From: | Daniel Brown | Date: | Thu, 05 Jul 2007 20:55:26 +0000 |
| Subject: | Re: About Website Search Engine | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258364@lists.php.net to get a copy of this message | ||
On 7/5/07, Kelvin Park <kelvinpark86@gmail.com> wrote:
I'm trying to build a search engine for my website (with php), it will have functions such as finding product names and their codes from the mysql database. Does anyone know any good tutorial or reference on any website, or any good books out there that you might recommend? I couldnt' find any decent one but only the ones that keep on saying, "use google search engine to search your website!" etc. Thanks!Kelvin, That depends. Is the content of your website dynamically-driven from content within the MySQL database you mentioned? If so, something like this would work: <? // Do your includes and database connection schemes here. if($_POST['search_data']) { $terms = mysql_real_escape_string($_POST['search_data']); $sql = "SELECT * FROM tablename WHERE $terms IN "; $sql .= "product_id,product_name,product_description"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) {
extract($row);
// Do your processing of each row of information here.
}
}
?>
<FORM METHOD="POST" ACTION="<?=$_SERVER['PHP_SELF'];?>">
Terms: <INPUT TYPE="TEXT" NAME="search_data"
VALUE="<?=$_POST['search_data'];?>"><BR />
<INPUT TYPE="SUBMIT" VALUE="Search">
</FORM>
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107