I'm making a website, where I display products that are registered in a database. In the table, there is a field that I call relevance and I wanted that when someone clicked on the image I would increment that field. I have no idea how to do this and wanted some tips. I tried by inclick of the image a php function that gave update in that field, but I know it does not work to do so by the way onclick works.
Although I knew it would not 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> ";}