Salve a tutti io avrei un problema, mi servirebbe che la select province cambiasse in base alla select Regione in modo da mostrare solo le province di quella regione e non tutte, qualcuno sa come posso fare ?
Grazie in anticipo
Grazie in anticipo
Codice:
<?php
$id = $_GET['id'];
$result = mysqli_query($mysqli, "SELECT * FROM clienti WHERE id=$id");
while($res = mysqli_fetch_array($result))
{
$nome = $res['nome'];
$cognome = $res['cognome'];
$rag_soc = $res['ragione_sociale'];
$indirizzo = $res['indirizzo'];
$citta = $res['citta'];
$cap = $res['cap'];
$provincia = $res['provincia'];
$regione = $res['regione'];
}
?>
<html>
<head>
<title>Edit Data</title>
<style>
.text{background-color: white}
.textWhite{background-color: #3399ff}
.button {
background-color: #008CBA;
border: none;
color: white;
padding: 8px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
margin-left: 785px ;
}
.space { margin-top: 120px; }
.fonttable{
font-size: 20;
font-weight: bold;
}
body {
background-image: url("img/1.png");
background-color: #cccccc;
}*/
</style>
</head>
<body>
<div class="space"></div>
<button class="button" onclick="window.location.href='/Clienti Def/index.php'">
<span>Home</span>
</button>
<br/><br/>
<form name="form1" method="post" action="edit.php">
<table border="0" align="center" cellspacing="8">
<tr>
<td class="fonttable">Nome</td>
<td><input type="text" name="nome" value="<?php echo $nome;?>"></td>
</tr>
<tr>
<td class="fonttable">Cognome</td>
<td><input type="text" name="cognome" value="<?php echo $cognome;?>"></td>
</tr>
<tr>
<td class="fonttable">Ragione sociale</td>
<td><input type="text" name="ragione_sociale" value="<?php echo $rag_soc;?>"></td>
</tr>
<tr>
<td class="fonttable">Indirizzo</td>
<td><input type="text" name="indirizzo" value="<?php echo $indirizzo;?>"></td>
</tr>
<tr>
<td class="fonttable">Citta</td>
<td><input type="text" name="citta" value="<?php echo $citta;?>"></td>
</tr>
<tr>
<td class="fonttable">CAP</td>
<td><input type="text" name="cap" value="<?php echo $cap;?>"></td>
</tr>
<tr>
<tr>
<td class="fonttable">Regione</td>
<td>
<select name='regione'>
<?php
$result1 = mysqli_query($mysqli, "SELECT * FROM italiareg");
$selected1 = "";
while($row=mysqli_fetch_array($result1)){
if ($row['itaregione'] === $regione) $selected1 = "selected";
else $selected1 = "";
echo "<option $selected1 value='".$row['itaregione']."'>".$row['itaregione']."</option>";
}
?>
</select>
</td>
</tr>
<td class="fonttable">Provincia</td>
<td><select name='provincia'>
<?php
$result1 = mysqli_query($mysqli, "SELECT * FROM province");
$selected = "";
while($row=mysqli_fetch_array($result1)){
if ($row['sigla'] === $provincia) $selected = "selected";
else $selected = "";
echo "<option $selected value='".$row['sigla']."'>".$row['nomeprovincia']."</option>";
}
?>
</select></td>
</tr>
<tr>
<td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td>
<td><input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
</body>
</html>