Current location - Health Preservation Learning Network - Healthy weight loss - How to realize the search function when making a website?
How to realize the search function when making a website?
Programming languages and database operations.

The details are as follows (I use PHP):

& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)

If (! Empty ($ TERM str))

{

Echo "& lthr & gtn";

$ cmdstr = " grep-I $ search str * ";

$fp = popen($cmdstr," r ");

$ my result = array();

while ($buffer = fgets ($fp,4096))

{

list($fname,$fline) = split(":",$buffer,2);

If (! Defined ($myresult[$fname]))

$ my result[$ fname]= $ fline;

}

if (count($myresult))

{

Echo "& LTOL & GTN";

while (list($fname,$fline) = each($myresult))

Echo "< Li>& ltHREF =" $ fname ">;; $ fname & lt/A & gt; : $ fline & lt/ Lee>N ";

Echo "& lt/OL & gt;; n”;

}

other

{

Echo "Sorry, there are no query results.

}

pclose($ FP);

}

& gt

The above is a simple search engine I have written.

Simple as it is, it is very practical.