I would like to know how to connect two select
. As if it had a category and a subcategory, but I want the subcategory to appear when I click on the category. I have two tables in the bd a member and another exercise, when I choose my member he list me all the exercises registered for that member.
Here, I'm showing my "category"
$database = new Database();
$db = $database->getConnection();
$exercicio = new exercicio($db);
$membro = new membro($db);
$stmt = $membro->read();
echo "<select class='form-control' name='membro_corpo'>";
echo "<option>Select Membro...</option>";
while ($row_category = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row_category);
echo "<option value='{$id_membro}'>{$nome_membro}</option>";
}
echo "</select>";
Now I want you to show me the "sub-categories" when I click on the category.
$stmt1 = $exercicio->read();
echo "<select class='form-control' name='category_id'>";
echo "<option>Select Exercicio...</option>";
while ($row_exercicio = $stmt1->fetch(PDO::FETCH_ASSOC)){
extract($row_exercicio);
if($exercicio->id_membro_exer==$id_membro){
echo "<option value='$id_membro' selected";
}else{
echo "<option value='$id_membro'";
}
echo "$nome_exer</option>";
}
echo "</select>";