Click to See Complete Forum and Search --> : Searching


Mouse77e
12-19-2005, 06:34 AM
Building a tailored search function for my site.

As my site has a set of fixed parameters to search I want to build a search engine along the following lines…

SELECT field_1, field2, field3 FROM mytable WHERE field1 LIKE '%my_seach_string%'

Building a form with four drop down lists of the major parameters and two free form boxes for the name and surname,

Would a full text search be better? (I am not so sure…)

Any Comments or suggestions?

Mouse

karnetics
12-19-2005, 11:55 AM
I have a advance search box settup on my site like this...

Search Form.php -----------------

Search box: searchbox

Dropdown field: table

Submit button
end Search Form.php --------------------

search Results.php -----------------------

//get the search box content if set
if (!isset($_GET['searchbox'])) {
$sql = "SELECT * FROM table";
} else {
$searchbox = $_GET['searchbox'];

//find out which table to search from
//set table varible
$table = $_GET['table'];

if ($table == 'new') {
$sql = SELECT * FROM $table WHERE Field1 LIKE '%$searchbox%';
}
elseif ($table == 'tutorials') {
$sql = SELECT * FROM $table WHERE Field1 LIKE '%$searchbox%';
}
}

$result = mysql_query($sql) or trigger_error(mysql_error());
$row = mysql_fetch_assoc($result);

karnetics
12-19-2005, 11:56 AM
if you would like to see my search box.. goto www.ledspace.com and click on the link advance in the search box.