Re: About Website Search Engine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/5/07, Kelvin Park <kelvinpark86@xxxxxxxxx> 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux