prepare("$sql"); $sth->execute(); list($id_cons)=$sth->fetch(PDO::FETCH_NUM); $sql="select id_sez from ".$prefix."_ele_sezioni where id_cons='$id_cons'"; $sth = $dbi->prepare("$sql"); $sth->execute(); $tot_sez = $sth->rowCount(); # Scelta argomento estrazione (gruppo,lista,candidati) $estrae='candidati'; # Carica array $sql="select t2.num_lista,t2.descrizione,t1.num_cand,t1.cognome,t1.nome,t3.voti,t4.num_sez from ".$prefix."_ele_candidati as t1 left join ".$prefix."_ele_lista as t2 on t1.id_lista=t2.id_lista left join ".$prefix."_ele_voti_candidati as t3 on t1.id_cand=t3.id_cand left join ".$prefix."_ele_sezioni as t4 on t3.id_sez=t4.id_sez where t1.id_cons='$id_cons' order by t2.num_lista,t1.num_cand,t4.num_sez"; $sth = $dbi->prepare("$sql"); $sth->execute(); $arsez=array(); $ar=array(); for ($i=1;$i<=$tot_sez;$i++) $arsez[$i+1]=$i; $arsez[$i+1]='TOTALE'; while(list($num_lista,$desc_lista,$num_cand,$cognome,$nome,$voti,$num_sez)=$sth->fetch(PDO::FETCH_NUM)) { /* $ar["$num_lista.0"][0]="\n$desc_lista"; $ar["$num_lista.$num_cand"][0]=str_replace("\t"," ","$cognome $nome"); if(!isset($ar["$num_lista.$num_cand"][1])) for($i=1;$i<=$tot_sez;$i++) */ $ar["$num_lista.$num_cand"][0]=str_replace("\t"," ","\n$cognome $nome"); $ar["$num_lista.$num_cand"][1]="$desc_lista"; if(!isset($ar["$num_lista.$num_cand"][2])) for($i=1;$i<=$tot_sez;$i++) $ar["$num_lista.$num_cand"][$i+1]="0"; $ar["$num_lista.$num_cand"][$num_sez+1]="$voti"; if(!isset($ar["$num_lista.$num_cand"][$i+1])) $ar["$num_lista.$num_cand"][$i+1]=0; $ar["$num_lista.$num_cand"][$i+1]+=$voti; } crea_tabella($ar,$arsez); function crea_tabella($ar,$arsez) { global $dbi,$prefix,$id_comune,$id_cons_gen; $sql="SELECT descrizione,simbolo,stemma FROM ".$prefix."_ele_comuni where id_comune='$id_comune' "; $res = $dbi->prepare("$sql"); $res->execute(); list($descr_comune,$simbolo,$stemma) = $res->fetch(PDO::FETCH_NUM); $sql="SELECT descrizione FROM ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen' "; $res = $dbi->prepare("$sql"); $res->execute(); list($descr_cons) = $res->fetch(PDO::FETCH_NUM); $datipdf="Comune di $descr_comune - Consultazione: $descr_cons
"; $datipdf=stripslashes($datipdf); $data=date("d-m-y G:i"); $nomefile=strip_tags(str_replace(array('"', "'", ' ', ','), "_", $datipdf).".xls"); header ("Content-Type: application/vnd.ms-excel"); header ("Content-Disposition: inline; filename=$nomefile"); $datipdf=str_replace("
","\n",$datipdf); $datipdf=strip_tags($datipdf); echo "$datipdf"; echo "\t"; foreach($arsez as $key=>$val) echo "\t$val"; foreach ($ar as $key1=>$riga2) { foreach ($riga2 as $key2=>$cella) { echo "$cella \t"; } } # echo"\n\n\nPowered by Eleonline http://www.eleonline.it \t \n"; # echo"by luciano apolito & roberto gigli - stampato: $data \t \n"; die(); } ?>