I have a database with several related tables, a product table related to one of categories, what I want is to show through a <select>
all the categories (that I can do) but when selecting a give me all the products that belong to that category!.
So I show the categories
<?php
$db = new mysqli('localhost', 'root', '', 'bd_productos3' );
if($db->connect_errno){
die('Error');
}
$result = $db->query("SELECT * FROM clasificacion");
$htmlPJ = '<form action="" method="post">';
$htmlPJ .= 'Clasificacion <select id="select">';
$sql = "select * from clasificacion";
while($row = $result->fetch_assoc()){
$htmlPJ.= "<option value='{$row['id_clasificacion']}' > {$row['nombre_clasificacion']} </option>";
}
$htmlPJ .= '</select>';
$htmlPJ .= '<input type="submit" value="Buscar" name="enviar">';
$htmlPJ .= '</form>';
echo $htmlPJ;
?>
I need when selecting a category to show me the products that are related to that category.
I appreciate your comments