ecco la funzione:


/*select =0 ricerca per codice
select =1 ricerca per titolo
select=2 attore
select=3 genere

*/






function ricercatitolo($select,$chiave){

if($select==0){
echo"$chiave";
$query=mysql_query("SELECT id, titolo, genere, attore1, attore2, attore3, trama, regia, durata, anno FROM film where id like '$chiave'")OR DIE("non riesco a selezionare");
$num_righe=mysql_num_rows($query);
if(!$num_righe){
return 0;
}
else{
return $query;
}

}


if($select==1){
$chiave=addslashes($chiave);
echo "$chiave";
/*mi stampa
$query=mysql_query("SELECT id, titolo, genere, attore1, attore2, attore3, trama, regia, durata, anno FROM film where titolo like '$chiave'")OR DIE("non riesco a selezionare");
$num_righe=mysql_num_rows($query);
if(!$num_righe){
return 0;
}
else{
return $query;
}

}

if($select==2){
echo "$chiave";
$query=mysql_query("SELECT id, titolo, genere, attore1, attore2, attore3, trama, regia, durata, anno FROM film where attore1 = ' $chiave ' or attore2 = ' $chiave ' or attore3 = ' $chiave '")OR DIE("non riesco a selezionare");
$num_righe=mysql_num_rows($query);
echo "$num_righe";

if(!$num_righe){
return 0;
}
else{
return $query;
}






}

if($select==3){
echo "$chiave";
$query=mysql_query("SELECT id, titolo, genere, attore1, attore2, attore3, trama, regia, durata, anno FROM film where genere =' $chiave ' ")OR DIE("non riesco a selezionare");
$num_righe=mysql_num_rows($query);
echo "$num_righe";

if(!$num_righe){
return 0;
}
else{
return $query;
}



}


}