$yourchoice = " WHERE $symptom LIKE '%$symptom%'"; if(!empty($manufacturer)) { $yourchoice = " AND $manufacturer LIKE '%$manufacturer%'"; } if(!empty($component)) { $yourchoice = " AND $component LIKE '%$component%'"; } // here is draft sql $result=MYSQL_QUERY(select $whatyouwant $fromyourtables $yourchoices $yourorder) or die (mysql_error());