Hello
I want to use a search engine based on text files and I found this one:
http://php.warpedweb.net/
I want to search with multiples criteria with text box,checkbox and radio button.
Basically I already have this code:
function s_search($query) {
// Searches for query in the index file.
// Multiple word search originally contributed by Matthew Furister <matt@agtown.com>
$query = trim(strtolower(c_strip_chars($query)));
$search_data = @file($GLOBALS[index_file]) or die("<h4 align=\"center\">$GLOBALS[err_no_search_db]</h4>");
$pages_found = " ";
foreach ($search_data as $search_page) {
$page_arr = explode("|", $search_page);
$found_count = 0;
$qry_array = split('[, ]+',trim(strtolower($query)));
foreach ($qry_array as $qry) {
if (in_array($qry, $page_arr)) {
++$found_count;
$pages_found .= $page_arr[0] . " ";
}
}
if ($found_count == count($qry_array)) $result_arr[] = $page_arr[0];
}
return $result_arr;
}
with the form here:
function s_print_search_form($query) {
// Function to print the search form.
?>
<div align="center"><form method="post">
<h4>Search for:</h4>
<input type="text" name="query" value="<?php echo $query ?>">
<input type="checkbox" name="query" value="Training"> Training<br>
<br><input type="submit" value="Search">
</form></div>
In this example, the last criteria is taken but the first one is not.
I want to be able to have something like this:
search.php?query=phil&training
If you have any idea, I would be interested to hear it.
thanks.