function validateForm() { var x=document.forms["form_candi"]["cognome"].value; if (x==null || x=="") { return false; } } '; # form echo '
Cerca il candidato
Inserisci il cognome o/e il nome intero del candidato da cercare
'; if(isset($_SESSION['cerca_cand'])) $cerca_cand=$_SESSION['cerca_cand']; else $cerca_cand=""; echo $cerca_cand; $_SESSION['cerca_cand']=''; $url=$_SERVER['REQUEST_URI']; // url della pagina per il reload $param=strtolower($_SERVER['REQUEST_METHOD']) == 'get' ? $_GET : $_POST; if (isset($param['cognome'])) get_magic_quotes_gpc() ? $cognome=$param['cognome']:$cognome=addslashes($param['cognome']); else $cognome=''; $chiave="$cognome"; global $id_comune; if($cognome!=''){ # divide nome e cognome $arr = explode(" ", $cognome); $num_arr=count($arr); if ($num_arr==2){ $cognome=$arr[0]; $nome=$arr[1]; $numeratore= " AND "; // cognome e nome }else{ $nome=$cognome; $numeratore= " OR "; // cognome o nome } $sql_cand= mysql_query("SELECT * FROM ".$prefix."_ele_candidati where (cognome like '%$cognome%' $numeratore nome like '%$nome%') OR (cognome like '%$nome%' $numeratore nome like '%$cognome%')", $dbi); $num_tot = mysql_num_rows($sql_cand); $res = mysql_query("SELECT * FROM ".$prefix."_ele_candidati where (cognome like '%$cognome%' $numeratore nome like '%$nome%') OR (cognome like '%$nome%' $numeratore nome like '%$cognome%') ORDER BY id_cand DESC LIMIT 0,7", $dbi); while (list($id_cand,$id_cons2,$id_lista,$cognome,$nome,$note,$simbolo,$num_candidato) = mysql_fetch_row($res)) { $res1 = mysql_query("SELECT id_cons_gen FROM ".$prefix."_ele_cons_comune where id_cons='$id_cons2'" , $dbi); list($id_cons_gen_cand) = mysql_fetch_row($res1); $res2 = mysql_query("SELECT descrizione, tipo_cons FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen_cand'" , $dbi); list($descr_consultazione,$tipo_consul) = mysql_fetch_row($res2); $res3 = mysql_query("SELECT descrizione FROM ".$prefix."_ele_lista where id_lista='$id_lista'" , $dbi); list($descr_lista) = mysql_fetch_row($res3); $res4 = mysql_query("select * from ".$prefix."_ele_sezioni where id_cons='$id_cons2'",$dbi); $sezioni=mysql_num_rows($res4); $cerca_cand .= "

"; $cerca_cand .= ""; if($tipo_consul!='4'){ // non รจ circoscrizione $cerca_cand .=" $cognome $nome $descr_consultazione - $descr_lista "; }else{ $cerca_cand .= "$cognome $nome $descr_consultazione - $descr_lista "; } $cerca_cand .='
'; } $cerca_cand .="
Trovati n.$num_tot con chiave $chiave"; if($num_tot>="8") $cerca_cand .="
Raffina la ricerca..."; $_SESSION['cerca_cand']=$cerca_cand; header("location:$url "); //$cognome=''; } ?>