Codice PHP:
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento senza titolo</title> <script type="text/javascript"> function dennis(){ document.MainForm.action="elaborazione.php"; document.MainForm.submit(); } </script> </head> <body> <table width="965" cellpadding="0" cellspacing="0"> <col width="62" /> <col width="396" /> <col width="410" /> <col width="76" /> <col width="124" /> <tr height="17"> <td colspan="4" height="17" align="center">Caratteristiche del territorio</td> </tr> <tr height="17"> <td colspan="4" height="17" align="center"><form name="MainForm" method="POST" ><select style="width:20%;" align="center" name="id_zona" select onChange='dennis()'> <option value=0 selected="selected" align="center">---Inserisci Territorio---</option> <option value=0>---------------------</option> <?php include_once("include/config.php"); $result = mysql_query(" SELECT id_zona,citta FROM `territorio` "); while($trg=mysql_fetch_array($result)) echo "<option name='id_zona' value=".$trg['id_zona']." name='id_zona' id='id_zona'>".$trg['citta']."</option> "; ?> </select></td> </tr> <?php include_once("include/connect.php"); if( isset($_GET['id_zona']) ) { $city=$_GET['id_zona']; $sql= "select * from territorio WHERE citta = '".$city."'"; $result = mysql_query($sql, $db); $q=mysql_fetch_array($result); $pop=$q['popolazione']; $pops=$q['pop_servita']; ?> <tr height="17"> <td width="359">Densità UTENTI, nr/kmq</td> <td width="108"> </td> <td width="408" align="right"><?php echo ($pop + $pops) ?></td> </tr> <?php } ?> </form> </body> </html>