5
I wonder how I connect two select
. As if it had a category and a sub-category, but I want the sub-category to appear when I click on the category. I have two tables in bd a member and another exercise, when I choose my member he lists me all the exercises registered to 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 in 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>";
You need to use ajax and javascript. I usually use jQuery on my websites. You use jQuery or just JS ?
– Diego Souza
Thanks. But I don’t know how to program yet with Jquery or Ajax. Anyway thanks.
– Arthur Balmanto