1
I’m doing a website, where I display products that are registered in a database. In the table, there is a field that I call relevancy and I wanted when someone clicked on the image to increase this field. I have no idea how to do this, and I wanted some tips. I tried to put in the image onclick a php function that update this field, but I know it doesn’t work to do so the way onclick works.
Although I knew it wouldn’t work, follow the code below to understand what I wanted to happen:
while($dados=mysql_fetch_array($sql)){
$aux=$dados['relevancia']+1;
$res= "UPDATE cwfolheados.produtos SET relevancia=".$aux." WHERE codigo=".$dados['codigo']."";
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> ";}