Hello, I'm doing a site where I need to change the query when I click on a link. For example, I have a product, ring, and I want to split into gold and silver ring. At the beginning of the page I made a query:
$sql= "SELECT * FROM produtos WHERE tipo='aneis' ORDER BY relevancia DESC";
there in the content of the page I created the links:
<ul>
<li ><a onclick="<?php $sql= "SELECT * FROM produtos WHERE tipo='aneis' ORDER BY relevancia DESC"; ?>">Todos</a></li>
<li ><a onclick="<?php $sql= "SELECT * FROM produtos WHERE tipo='aneis' AND classificacao='ouro' ORDER BY relevancia DESC"; ?>">Ouro</a></li>
<li ><a onclick="<?php $sql= "SELECT * FROM produtos WHERE tipo='aneis' AND classificacao='prata' ORDER BY relevancia DESC"; ?>">Prata</a></li>
</ul>
And my images are below, like this:
$sql1=mysql_query($sql);
while($dados=mysql_fetch_array($sql1)){
echo "<li><a href=".$dados['foto']." onclick='".mysql_query($res)."' style=' margin-left:0' data-lightbox='image-1' data-title=".$aux2.">
<img style=' width:200px; height:150px; ' border='0' alt='image 02' src=".$dados['foto']." />
<figcaption>".$dados['nome']." - ".$dados['codigo']."</figcaption></a></li> ";}
However, he performs, at the beginning the last query, selecting only the silver products. And I wanted it to show everyone at first, and when I clicked on the gold link, for example, it would refresh the page just with the gold rings.