I'm doing two select, the category and subcategory. Both via MySQL. I would like that when selecting the category, pass the category ID to the Subcategory.
$rsCategoria = $conexao->query("SELECT * FROM categoria WHERE idioma = 'pt-br' ");
$rsSubcategoria = $conexao->query("SELECT * FROM categoriasub WHERE id_categoria = '{$id_categoria}' AND idioma = 'pt-br' ");
.
<select id="categoria" name="categoria" class="input form-control col-lg-10" required>
<option value="" selected="selected">Selecione</option>
<?php while ($rowCategoria = $rsCategoria->fetch_assoc()) {?>
<option value="<?php echo $rowCategoria['ID_Categoria'] ?>"><?php echo $rowCategoria['nome'] ?></option>
<?php } ?>
</select>
<select id="subcategoria" name="subcategoria" class="input form-control col-lg-10" style="margin-top: 20px;">
<option value="" selected="selected">Selecione</option>
<?php while ($rowSubcategoria = $rsSubcategoria->fetch_assoc()) {?>
<option value="<?php echo $rowSubcategoria['ID_Categoria'] ?>"><?php echo $rowSubcategoria['nome'] ?></option>
<?php } ?>
</select>
What would be the best way to find the subcategory?