I'm creating some filters to search for products, having the products all visible, I would like to know how I can make a selection field and through the category that the user chooses, only the products of that category would appear. I have the following code:
Search for Categories:
<form action="#" method="post">
<select name="categoria">
<option value="omega3">Ómega-3</option>
<option value="probioticos">Probióticos</option>
<option value="nutrientes">Nutrientes Essênciais</option>
<option value="plantas">Plantas Medicinais</option>
</select>
</form>
<div class="row">
<?
$tag = $_POST['categoria'];
$result = $connection -> query("select * from produtos where tags like '%$tag%' order by id limit 4");
while($row = $result -> fetch_array(MYSQLI_ASSOC)){
$id = $row['id'];
$titulo = $row['titulo'];
$resumo = $row['resumo'];
$imagem = $row['imagem'];
?>
<div class="grid_3">
<div class="box2 wrap1 wow fadeInLeft" data-wow-delay="0.1s">
<a href="verproduto.php?id=<?=$id?>"><img class="first" src="<?=$imagem?>" alt=""/></a>
<div class="caption bggreen equal">
<h6 class="text_3 colorblue">
<a href="verproduto.php?id=<?=$id?>""><?=$titulo?></a>
</h6>
<br>
<p class="colorwhite">
<?=$resumo?>
</p>
</div>
</div>
</div>
<?
}
$result -> free();
?>