prepare("$sql"); $res->execute(); list($tipo_cons,$descr_cons,$id_cons) = $res->fetch(PDO::FETCH_NUM); include("modules/Elezioni/funzionidata.php"); include("modules/Elezioni/ele.php"); // Offset - visualizza il numero di elementi per pagina if (isset($_GET['do'])) $do=addslashes($param['do']); else $do=''; if (isset($_GET['min'])) $min=intval($_GET['min']); else $min=0; if (isset($_GET['id_circ'])) $id_circ=intval($_GET['id_circ']); else $id_circ=''; if (isset($_GET['ok'])) $ok=intval($_GET['ok']); else $ok=''; if (isset($_GET['num_circ'])) $num_circ=intval($_GET['num_circ']); else $num_circ=''; if (isset($_GET['descr_circ'])) $descr_circ=addslashes($param['descr_circ']); else $descr_circ=''; $offset=10; $hiddenInfo = ""; /******************************************************/ /*Funzione di visualizzazione globale */ /*****************************************************/ function all() { global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $offset, $min, $id_cons,$id_cons_gen,$do,$id_circ; echo "

"._CIRCO."


"; echo "
" ."" .""; echo ""; echo "" ."" .""; if ($do == "modify"){ $sql = "SELECT * FROM ".$prefix."_ele_circoscrizione where id_circ='$id_circ'"; $res = $dbi->prepare("$sql"); $res->execute(); $pro= $res->fetch(PDO::FETCH_BOTH); echo "" .""; echo ""; echo "" .""; } else { $sql = "select max(num_circ) from ".$prefix."_ele_circoscrizione where id_cons='$id_cons'"; $result = $dbi->prepare("$sql"); $result->execute(); list($numc)=$result->fetch(PDO::FETCH_NUM); $numc++; echo "" .""; echo ""; } $sql = "SELECT * FROM ".$prefix."_ele_circoscrizione where id_cons='$id_cons' "; $res = $dbi->prepare("$sql"); $res->execute(); $max = $res->rowCount(); $sql="select * from ".$prefix."_ele_circoscrizione where id_cons='$id_cons' ORDER BY num_circ LIMIT $min,$offset"; $result = $dbi->prepare("$sql"); $result->execute(); while(list($id_cons2, $id_circ, $num_sez, $descr_circ) = $result->fetch(PDO::FETCH_NUM)) { $sql="select count(0) from ".$prefix."_ele_sede where id_circ='$id_circ'"; $restemp = $dbi->prepare("$sql"); $restemp->execute(); list($numtemp)=$restemp->fetch(PDO::FETCH_NUM); $bgcolor1=($bgcolor1==$_SESSION['bgcolor1'])?$_SESSION['bgcolor2']:$_SESSION['bgcolor1']; echo ""; } echo "
"._NUM." "._DESCR." "._FUNZIONI."
$num_sez" ."$descr_circ" ."[\"edit\" "._EDIT."]"; if (!$numtemp) echo "["._DELETE." \"delete\"]"; else echo "["._DELETE." \"delete\"]"; echo "
"; #'Pagina precedente' e 'Pagina Successiva' if ($max>$offset){ echo""; $prev=$min-$offset; if ($prev>=0) { echo ""; } $next=$min+$offset; if ($next>=($offset-1)) { if($next>=$max) $next = $max; else { echo ""; } } echo "
"; echo "$offset "._PREV_MATCH.""; echo "$offset "._NEXT_MATCH."

"; } } //*********************************** // Consultazione // ricordarsi di aggiungere l'eliminazione di tutti // i dati della consultazione nelle altre tabelle // hai capito? //*********************************** function circo($ok, $do, $id_cons ,$num_circ,$descr_cons, $id_circ, $descr_circ) { global $aid, $prefix, $dbi, $id_cons_gen; $perms= ChiSei($id_cons_gen); if ($perms>16) { if ($do == "delete") { if ($ok !="1") { ele(); echo "


"._DOMCANCELLA." $descr_circ ?
"; echo "[ "._NO." ] - ["._YES." ]"; include("footer.php"); die(); }else{ $sql="select num_circ from ".$prefix."_ele_circoscrizione where id_circ=$id_circ"; $rescirc = $dbi->prepare("$sql"); $rescirc->execute(); if ($rescirc->rowCount()!=1) die("(1001) Grave errore nel database! contattare l'amministratore"); list($num_circ)=$rescirc->fetch(PDO::FETCH_NUM); $sql="delete from ".$prefix."_ele_circoscrizione where id_circ='$id_circ'"; $result = $dbi->prepare("$sql"); $result->execute(); $sql="select id_circ,num_circ from ".$prefix."_ele_circoscrizione where num_circ>$num_circ and id_cons=$id_cons"; $rescirc = $dbi->prepare("$sql"); $rescirc->execute(); while (list($tmp_id,$tmp_num)=$rescirc->fetch(PDO::FETCH_NUM)){ $sql="update ".$prefix."_ele_circoscrizione set num_circ=".($tmp_num-1)." where id_circ=$tmp_id"; $result = $dbi->prepare("$sql"); $result->execute(); } Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen"); } }elseif ($do == "add") { if ($descr_circ) { $sql="insert into ".$prefix."_ele_circoscrizione (id_cons,num_circ,descrizione) values ('$id_cons','$num_circ','$descr_circ')"; $result = $dbi->prepare("$sql"); $result->execute(); Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen"); } }elseif ($do == "update") { $sql="update ".$prefix."_ele_circoscrizione set num_circ='$num_circ' , descrizione='$descr_circ' WHERE id_circ='$id_circ'"; $result = $dbi->prepare("$sql"); $result->execute(); Header("Location: admin.php?op=circo&id_cons_gen=$id_cons_gen"); } } } if ($do!= "") circo($ok,$do, $id_cons,$num_circ,$descr_cons,$id_circ,$descr_circ); ele(); all(); echo""; include("footer.php"); ?>