ho provato a fare una cosa del genere:
Codice PHP:
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") {
selectCategory();
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" name="cat" method="post">
<tr>
<td>Sezione:</td>
<td>
<select name="sezione" onchange="document.forms['cat'].submit();">
<option value="*">*</option>
<?php
foreach (selectSection () as $rowSection) {
echo "<option value='" . $rowSection['sezione_id'] . "'>" . $rowSection['sezione_nome'] . "</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Categoria:</td>
<td>
<select name="categoria" id="categoria">
<option value="*">*</option>
<?php
foreach (selectCategory () as $rowCat) {
echo "<option value='" . $rowCat['categoria_id'] . "'>" . $rowCat['categoria_nome'] . "</option>";
}
?>
</select>
</td>
</tr>
</form>
il metodo selectCategory:
Codice PHP:
function selectCategory() {
global $config;
$sec = $_POST['sezione'];
try {
$result = $config->getPdo()->query("SELECT * FROM categorie WHERE sezione_FK=" . $sec . " ORDER BY categoria_nome");
return $result;
} catch (Exception $e) {
die($e->getMessage());
}
}
ovviamente nn ha funzionato.
nessuno ha qualche idea??