source: trunk/client/file.php@ 342

Last change on this file since 342 was 265, checked in by roby, 6 years ago
File size: 1.8 KB
RevLine 
[2]1<?php
2
3include("config.php");
[265]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 }
[2]13$fase=intval($_GET['fase']);
14
[265]15
[2]16if ($fase=='1'){
[265]17 $sql="SELECT id_cons_gen,descrizione from ".$prefix."_ele_consultazione order by descrizione";
18 $res = $dbi->prepare("$sql");
19 $res->execute();
20
[2]21Header("content-type: application/x-javascript");
22echo "document.write(\"<b><select name=\'id_cons_gen2\'>";
23
[265]24while(list($id_cons_gen2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
[2]25 echo "<option value=\'$id_cons_gen2\'>$descr";
26 }
27 echo "</select>";
[265]28 $res = $dbi->prepare("$sql");
29 $res->execute();
30while(list($id_cons_gen2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
[2]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']);
[265]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
[2]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
[265]49while(list($id_comune2,$descr) = $res->fetch(PDO::FETCH_NUM)) {
[2]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.