Ignore:
Timestamp:
Apr 13, 2019, 8:05:15 PM (5 years ago)
Author:
roby
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/modules/Elezioni/confronti.php

    r105 r265  
    5353        $x++;
    5454}*/
    55 $res = mysql_query("SELECT t1.descrizione,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.id_cons_gen=t2.id_cons_gen and t1.tipo_cons=t3.tipo_cons and t3.circo='0' and t3.genere>'2' and t2.id_comune='$id_comune' order by t1.data_fine,t1.descrizione", $dbi);
    56 if (mysql_num_rows($res)){
     55$sql="SELECT t1.descrizione,t2.id_cons FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2, ".$prefix."_ele_tipo as t3 where t1.id_cons_gen=t2.id_cons_gen and t1.tipo_cons=t3.tipo_cons and t3.circo='0' and t3.genere>'2' and t2.id_comune='$id_comune' order by t1.data_fine,t1.descrizione";
     56$res = $dbi->prepare("$sql");
     57$res->execute();
     58if ($res->rowCount()){
    5759        echo "<form id=\"cons\" action=\"modules.php\">";
    5860        echo "<table><tr><td>"
     
    6769                <tr><td align=\"center\" colspan=\"2\"><br/>"._SCELTA_CONS."</td></tr>";
    6870        $x=1;
    69         while (list($descr_cons,$id_cons)= mysql_fetch_row($res)){
     71        while (list($descr_cons,$id_cons)= $res->fetch(PDO::FETCH_NUM)){
    7072                echo "<tr><td>$descr_cons</td><td><input type=\"checkbox\" name=\"check$x\"/>";
    7173                echo "<input type=\"hidden\" name=\"cons$x\" value=\"$id_cons\"/>";
     
    148150        if($pag>=$pags) return(1); //in $pags il numero delle consultazioni
    149151        $id_cons2=$_SESSION['confr'][$pag];
    150         $res_lis = mysql_query("SELECT t1.descrizione,t1.tipo_cons,t2.id_conf from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons='$id_cons2'",$dbi);
    151         list($descr,$tipoc,$legge)=mysql_fetch_row($res_lis);
     152        $sql="SELECT t1.descrizione,t1.tipo_cons,t2.id_conf from ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_cons='$id_cons2'";
     153        $res_lis = $dbi->prepare("$sql");
     154        $res_lis->execute();
     155
     156        list($descr,$tipoc,$legge)=$res_lis->fetch(PDO::FETCH_NUM);
    152157        if($legge){
    153                 $res_l=mysql_query("SELECT limite from  ".$prefix."_ele_conf where id_conf='$legge'",$dbi);
    154                 list($limite)=mysql_fetch_row($res_l);
     158                $sql="SELECT limite from  ".$prefix."_ele_conf where id_conf='$legge'";
     159                $res = $dbi->prepare("$sql");
     160                $res->execute();
     161
     162                list($limite)=$res->fetch(PDO::FETCH_NUM);
    155163        }
    156164if($tipoc==3 and $fascia<=$limite){
    157165        $_SESSION['grulis'][$id_cons2]='1';
    158         $res_lis = mysql_query("SELECT t2.id_gruppo,t1.descrizione,t2.descrizione from ".$prefix."_ele_lista as t1 left join ".$prefix."_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons2' order by t2.num_gruppo",$dbi);
     166        $sql="SELECT t2.id_gruppo,t1.descrizione,t2.descrizione from ".$prefix."_ele_lista as t1 left join ".$prefix."_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons2' order by t2.num_gruppo";
     167
    159168}else{
    160         $res_lis = mysql_query("SELECT t1.id_lista,t1.descrizione,t2.descrizione from ".$prefix."_ele_lista as t1 left join ".$prefix."_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons2' order by t2.num_gruppo",$dbi);
     169        $sql="SELECT t1.id_lista,t1.descrizione,t2.descrizione from ".$prefix."_ele_lista as t1 left join ".$prefix."_ele_gruppo as t2 on t1.id_gruppo=t2.id_gruppo where t1.id_cons='$id_cons2' order by t2.num_gruppo";
    161170        $_SESSION['grulis'][$id_cons2]='0';
    162171        }
    163         $yy=mysql_num_rows($res_lis);
     172$res_lis = $dbi->prepare("$sql");
     173$res_lis->execute();
     174
     175        $yy=$res_lis->rowCount();
    164176        if ($yy){
    165177                echo "<form name=\"liste\" action=\"modules.php\">"
     
    177189                echo "</tr>";
    178190                        $z=1;
    179                         while(list($id_lista,$descr,$gruppo) = mysql_fetch_row($res_lis)) {
     191                        while(list($id_lista,$descr,$gruppo) = $res_lis->fetch(PDO::FETCH_NUM)) {
    180192                                $_SESSION['num_lista'.$z]=$id_lista;
    181193                                echo "<tr><td>$gruppo</td><td>$descr</td>";
     
    200212$riga5="<tr align=\"center\"><td>"._VOTANTI."</td>";
    201213foreach($_SESSION['confr'] as $y=>$x){
    202         $res= mysql_query("SELECT sum(maschi+femmine) from ".$prefix."_ele_sezioni where id_cons='$x'",$dbi);
    203         list($elet)=mysql_fetch_row($res);
     214        $sql="SELECT sum(maschi+femmine) from ".$prefix."_ele_sezioni where id_cons='$x'";
     215        $res = $dbi->prepare("$sql");
     216        $res->execute();
     217
     218        list($elet)=$res->fetch(PDO::FETCH_NUM);
    204219        if($_SESSION['grulis'][$x]=='1')
    205                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_cons='$x'",$dbi);
     220                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_cons='$x'";
    206221        else
    207                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$x'",$dbi);
    208         list($tot[$y])=mysql_fetch_row($res);
    209         $res = mysql_query("SELECT t1.descrizione FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' and t2.id_cons='$x'", $dbi);
    210         list($descr)=mysql_fetch_row($res);
     222                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_cons='$x'";
     223        $res = $dbi->prepare("$sql");
     224        $res->execute();
     225
     226        list($tot[$y])=$res->fetch(PDO::FETCH_NUM);
     227        $sql="SELECT t1.descrizione FROM ".$prefix."_ele_consultazione as t1, ".$prefix."_ele_cons_comune as t2 where t1.id_cons_gen=t2.id_cons_gen and t2.id_comune='$id_comune' and t2.id_cons='$x'";
     228        $res = $dbi->prepare("$sql");
     229        $res->execute();
     230        list($descr)=$res->fetch(PDO::FETCH_NUM);
    211231        $riga1.="<td>$descr</td>";
    212232        $riga5.="<td>".$tot[$y]."<br/>".number_format($tot[$y]*100/$elet)."%</td>";
     
    342362                foreach ($_SESSION['grp1'][$x] as $key=>$val){
    343363                        if($_SESSION['grulis'][$id_cons2]=='1')
    344                                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'",$dbi);
     364                                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'";
    345365                        else
    346                                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
    347                         list($voti)=mysql_fetch_row($res);
     366                                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'";
     367                        $res = $dbi->prepare("$sql");
     368                        $res->execute();
     369
     370                        list($voti)=$res->fetch(PDO::FETCH_NUM);
    348371                        $ar1[$x]+=$voti;
    349372                }
    350373                foreach ($_SESSION['grp2'][$x] as $key=>$val){
    351374                        if($_SESSION['grulis'][$id_cons2]=='1')
    352                                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'",$dbi);
     375                                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'";
    353376                        else
    354                                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
    355                         list($voti)=mysql_fetch_row($res);
     377                                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'";
     378                        $res = $dbi->prepare("$sql");
     379                        $res->execute();
     380
     381                        list($voti)=$res->fetch(PDO::FETCH_NUM);
    356382                        $ar2[$x]+=$voti;
    357383                }
    358384                foreach ($_SESSION['grp3'][$x] as $key=>$val){
    359385                        if($_SESSION['grulis'][$id_cons2]=='1')
    360                                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'",$dbi);
     386                                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_gruppo where id_gruppo='$val'";
    361387                        else
    362                                 $res= mysql_query("SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'",$dbi);
    363                         list($voti)=mysql_fetch_row($res);
     388                                $sql="SELECT sum(voti) from ".$prefix."_ele_voti_lista where id_lista='$val'";
     389                        $res = $dbi->prepare("$sql");
     390                        $res->execute();
     391
     392                        list($voti)=$res->fetch(PDO::FETCH_NUM);
    364393                        $ar3[$x]+=$voti;
    365394                }
Note: See TracChangeset for help on using the changeset viewer.