faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 25 people (24%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

how can I create a search engine to my MySQL database such as the existing in this web site?

Nov 14th, 2002 20:51
Dave, Flavio Cambraia,


The php file where you write your query should have $text (the query) and $in (the field) in it.
Then the result:
$result0 = mysql_query("SELECT data1, data2, data3 FROM table WHERE $in LIKE '%$text%' ORDER BY data1");
while(list($data12, $data22, $data32) = mysql_fetch_row($result0)) {
// listing the data
echo "$data12";
echo "$data22";
echo "$data32";
echo "<hr>";
}