PHP search options

Hi I have this serach function, wich searches on site by a lot of parameters at the same time (titolo, titolo2, attore1,etc…) , but I want to make them options, so you would have a search field and an options dropdown menu.

Can anyone help me with this?

My code follows:
PHP

function jm_search(){
		global $database, $sstring, $my, $cinConfig, $Itemid, $option, $mainframe;	
		
		$tl_title = _JMOVIES_SEARCHRESULT." ".$sstring;
		
		$suchstring = trim( strtolower( $sstring ) );
		$query1   = "SELECT * FROM #__jmovies WHERE"
		."\
 (titolo LIKE '%".$suchstring."%'"
		."\
 OR titolo2 LIKE '%".$suchstring."%'"
		."\
 OR attore1 LIKE '%".$suchstring."%'"
		."\
 OR attore2 LIKE '%".$suchstring."%'"
		."\
 OR attore3 LIKE '%".$suchstring."%'"
		."\
 OR attore4 LIKE '%".$suchstring."%'"
		."\
 OR nazione LIKE '%".$suchstring."%'"
		."\
 OR regista LIKE '%".$suchstring."%'"
		."\
 OR descrizione LIKE '%".$suchstring."%'"
		."\
 OR anno LIKE '%".$suchstring."%') AND published = 1 AND access <= ".(int)$my->gid." ORDER BY titolo";
		$database->setQuery($query1);
		//echo $database->getQuery();
		$rows = $database->loadObjectList();

		if(is_file($mainframe->getCfg('absolute_path')."/components/".$option."/templates/".$cinConfig['template']."/show_search_tpl.php"))
			require($mainframe->getCfg('absolute_path')."/components/".$option."/templates/".$cinConfig['template']."/show_search_tpl.php");
		else
			require($mainframe->getCfg('absolute_path')."/components/".$option."/templates/default/show_search_tpl.php");
		
	}

HTML

<td width="44%" valign="middle" bgcolor="#eeeeee" style="text-align:right">
      <input name="sstring" type="text" class="jmoviesInputSearch" title="<?php echo _JMOVIES_SEARCH?>" onfocus="if(this.value=='<?php echo _JMOVIES_SEARCH?>') this.value='';" onblur="if(this.value=='') this.value='<?php echo _JMOVIES_SEARCH?>';" onchange="javascript:document.jmoviesSearchForm.submit();" value="<?php echo _JMOVIES_SEARCH?>" size="50"/><input type="submit" value="OK" class="button"/></td>

Thank you.

You want to create a query builder which would work similar to that below:


$where_clauses = "";

if(isset($_GET['anno'])){

$where_clauses .= " AND anno = ' . $_GET['anno'] .',' ;

}

// add more clauses similar to the above, 
// concatonate the string

// later ...

$query = "select * from movies WHERE
                       titolo like '%$term%' " . rtrim( $where_clauses, ',') ;

So if your url was /search.php?term=scotty&anno=1999;

your sql should look like

select * from movies where titolo like ‘%scotty%’ AND anno = 1999;

The key is to get your sql working, make some sample queries, then get PHP to create the exact same string, dont test PHP generated sql statements directly into the database at first. Split the job up.