When I execute the input (BTN) it counts all the rows of the products of the DB, it is not telling me when I select only a specific product:
My table is called "products"
id Nombre precio stock ruta voto
1 Camisas $5.00 35 img/camisa.jpg 2
2 casacas $55.00 55 img/casacas.jpg 2
3 boxer $67.00 20 img/boxer.jpg 2
4 zapatos $45.00 15 img/zapatos.jpg 2
PHP script "voto.php"
<?php
require_once("conn.php");
$strSQL_Result = mysqli_query($connection,"select 'voto' from
'productos' where id=id");
$row = mysqli_fetch_array($strSQL_Result);
$voto = $row['voto'];
if($_POST)
{
if(isset($_COOKIE["counter_gang"]))
{
echo "-1";
exit;
}
setcookie("counter_gang", "votos", time()+3600*24);
if(mysqli_real_escape_string($connection,$_POST['up']) == 'voto')
{
$update = "'voto'='voto'+1";
}
mysqli_query($connection,"update 'productos' set $update where 'id'='id'");
echo 1;
exit;
}
?>
My JS script "sumarVoto.js"
$(document).ready(function() {
$("#votar").removeAttr("disabled");
$('#votar').click(function(e)
{
var val = parseInt($("#votar").val(), 10);
$.post("voto.php", {up:"voto"},function(data)
{
if(data==1)
{
$("#status").html("Voto Exitosamente!!");
val = val+1;
$("#votar").val(val);
$("#votar").attr("disabled", "disabled");
$("#votar").css("background-image","url(voto1.png)");
}
else
{
$("#status").html("Ya vote!!");
}
})
});
});
HTML:
<div>
<input id="votar" type="submit" value="votar">
<span id="status">...</span>
</div>
When I execute the normal input, it executes but the error is that it adds up all the rows of the "products" table and the COOKIE does not work for me either