[2] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | include("config.php");
|
---|
[265] | 4 | try{
|
---|
[360] | 5 | $dbi = new PDO("mysql:host=$dbhost;charset=utf8", $dbuname, $dbpass, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION));
|
---|
[265] | 6 | $sql = "use $dbname";
|
---|
| 7 | $dbi->exec($sql);
|
---|
| 8 | }
|
---|
| 9 | catch(PDOException $e)
|
---|
| 10 | {
|
---|
| 11 | echo $sql . "<br>" . $e->getMessage();
|
---|
| 12 | }
|
---|
[360] | 13 | $sth = $dbi->prepare("SET NAMES 'utf8'");
|
---|
| 14 | $sth->execute();
|
---|
| 15 |
|
---|
| 16 |
|
---|
[2] | 17 | $fase=intval($_GET['fase']);
|
---|
| 18 |
|
---|
[265] | 19 |
|
---|
[2] | 20 | if ($fase=='1'){
|
---|
[265] | 21 | $sql="SELECT id_cons_gen,descrizione from ".$prefix."_ele_consultazione order by descrizione";
|
---|
| 22 | $res = $dbi->prepare("$sql");
|
---|
| 23 | $res->execute();
|
---|
| 24 |
|
---|
[360] | 25 | Header("content-type: application/x-javascript; charset=utf-8");
|
---|
[2] | 26 | echo "document.write(\"<b><select name=\'id_cons_gen2\'>";
|
---|
| 27 |
|
---|
[265] | 28 | while(list($id_cons_gen2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[360] | 29 | echo "<option value=\'$id_cons_gen2\'>$descr</option>";
|
---|
[2] | 30 | }
|
---|
| 31 | echo "</select>";
|
---|
[265] | 32 | $res = $dbi->prepare("$sql");
|
---|
| 33 | $res->execute();
|
---|
| 34 | while(list($id_cons_gen2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[2] | 35 | echo "<input type=\'hidden\' name=\'$id_cons_gen2\' value=\'$descr\'>";
|
---|
| 36 | }
|
---|
| 37 | echo "</b>\")";
|
---|
| 38 |
|
---|
| 39 | }elseif ($fase=='2'){
|
---|
| 40 | $id_cons_gen2=intval($_GET['id_cons_gen2']);
|
---|
[265] | 41 | $sql="SELECT descrizione from ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen2'";
|
---|
| 42 | $rescons = $dbi->prepare("$sql");
|
---|
| 43 | $rescons->execute();
|
---|
| 44 |
|
---|
| 45 | list($descr_cons) = $rescons->fetch(PDO::FETCH_NUM);
|
---|
| 46 | $sql="SELECT t2.id_comune,t2.descrizione from ".$prefix."_ele_cons_comune as t1 left join ".$prefix."_ele_comuni as t2 on t1.id_comune=t2.id_comune where t1.id_cons_gen=$id_cons_gen2 order by t2.descrizione ";
|
---|
| 47 | $res = $dbi->prepare("$sql");
|
---|
| 48 | $res->execute();
|
---|
| 49 |
|
---|
[360] | 50 | Header("content-type: application/x-javascript; charset=utf-8");
|
---|
[2] | 51 | echo "document.write(\"<b><input type=\'hidden\' name=\'id_cons_gen2\' value=\'$id_cons_gen2\'><select name=\'id_comune2\'>";
|
---|
| 52 |
|
---|
[265] | 53 | while(list($id_comune2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
|
---|
[360] | 54 | echo "<option value=\'$id_comune2\'>$descr</option>";
|
---|
[2] | 55 | }
|
---|
| 56 | echo "</select>";
|
---|
| 57 | echo "</b>\")";
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | ?>
|
---|