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