I found this tutorial rather helpful when I needed to create a search.
You'll need to exand on it a little though.
Personally, I just concatenated my strings into one, then exploded them into an array. My code will look a little confusing until your read the tutorial.
http://moskalyuk.com/php/yourownsearchengine.htm
$results = array();
$arr = strtolower($name." ".$csz." ".$pro);
$qarr1 = explode(" ", $arr);
$qnum = count($qarr1);
for($i=0;$i<$qnum;$i++){
if(empty($qarr1[$i]))
unset($qarr1[$i]);
}
$qarr = array();
foreach($qarr1 as $key => $val){
$qarr[] = $val;
}
$qnum = count($qarr);
if($pro == "")
$query = mysql_query("SELECT id, categorykey, name, csz FROM members");
if($pro !== "")
$query = mysql_query("SELECT id, categorykey, name, csz FROM members WHERE categorykey='".$pro."'");
$tot_rows = mysql_num_rows($query);
for($c=0; $c<$tot_rows; $c++){
$relevancy = 0;
$row = mysql_fetch_array($query);
$mid = $row['id'];
$rarr = strtolower($row['name']." ".str_replace($replace, "", $row['csz'])." ".str_replace($replace, "", $row['categorykey']));
for($d=0; $d<$qnum; $d++){
$relevancy += substr_count($rarr, $qarr[$d]);
}
if($relevancy > 0){
$results["$mid"] = $relevancy;
}
if(count($results) > 0)
arsort($results);
}//end for $c<=$tot_rows
The results will be sorting in ascending order. Just use a foreach statement to get when you need.
Please be advised that my code is just an example of how to do it, it won't work for perfectly for your needs.