source: trunk/client/file.php@ 358

Last change on this file since 358 was 265, checked in by roby, 6 years ago
File size: 1.8 KB
Line 
1<?php
2
3include("config.php");
4 try{
5 $dbi = new PDO("mysql:host=$dbhost;charset=latin1", $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$fase=intval($_GET['fase']);
14
15
16if ($fase=='1'){
17 $sql="SELECT id_cons_gen,descrizione from ".$prefix."_ele_consultazione order by descrizione";
18 $res = $dbi->prepare("$sql");
19 $res->execute();
20
21Header("content-type: application/x-javascript");
22echo "document.write(\"<b><select name=\'id_cons_gen2\'>";
23
24while(list($id_cons_gen2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
25 echo "<option value=\'$id_cons_gen2\'>$descr";
26 }
27 echo "</select>";
28 $res = $dbi->prepare("$sql");
29 $res->execute();
30while(list($id_cons_gen2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
31 echo "<input type=\'hidden\' name=\'$id_cons_gen2\' value=\'$descr\'>";
32 }
33echo "</b>\")";
34
35}elseif ($fase=='2'){
36 $id_cons_gen2=intval($_GET['id_cons_gen2']);
37 $sql="SELECT descrizione from ".$prefix."_ele_consultazione where id_cons_gen='$id_cons_gen2'";
38 $rescons = $dbi->prepare("$sql");
39 $rescons->execute();
40
41 list($descr_cons) = $rescons->fetch(PDO::FETCH_NUM);
42 $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 ";
43 $res = $dbi->prepare("$sql");
44 $res->execute();
45
46Header("content-type: application/x-javascript");
47echo "document.write(\"<b><input type=\'hidden\' name=\'id_cons_gen2\' value=\'$id_cons_gen2\'><select name=\'id_comune2\'>";
48
49while(list($id_comune2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
50 echo "<option value=\'$id_comune2\'>$descr";
51 }
52 echo "</select>";
53echo "</b>\")";
54}
55
56
57?>
Note: See TracBrowser for help on using the repository browser.