1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
	!include_once "<your php file for connection>";
?>

<div id="regioni">
<label for="REGIONI"> REGIONI: </label>
<select name="REGIONI" ID="regionisel" onchange="javascript:valueselect(this)">

<?php
	$query="SELECT Codice, Denominazione FROM GpEParRegioni ORDER BY Denominazione";
	if ($result = $mysqli->query($query)) {
		while ($rowCerts = $result->fetch_assoc()) {
			echo "<option value=\"{$rowCerts['Codice']}\">";
		  echo $rowCerts['Denominazione'];
		  echo "</option>";
		}
	}
	else {
		printf("Errore nell'esecuzione della query!\n");
		print_r($mysqli->error_list);
	}
	
	/* close connection */
	$mysqli->close();
?>
</select>
</div>

<script>
   function valueselect(sel) {
      var value = sel.options[sel.selectedIndex].value;
      var regione = sel.options[sel.selectedIndex].text;
      window.location.href = "comuni_page02.php?selected="+value+"&regione="+regione;
   }
</script>