-2
I would like to know how to get individual values of each like button, because when I like once a comment it ends up receiving the amount of others... Example; If you have 2 comments you get 2Likes, if 3 gets 3 and so on...
Follows the code
<?php
$selecionaLike = "SELECT * FROM likes WHERE idcomentario = '$idComentarioLinha'";
$execSelecionaLike = mysqli_query($conexaoBanco, $selecionaLike);
$contaLike = mysqli_num_rows($execSelecionaLike);
$selecionaDeslike = "SELECT * FROM deslike WHERE idcomentario = '$idComentarioLinha'";
$execSelecionaDeslike = mysqli_query($conexaoBanco, $selecionaDeslike);
$contaDeslike = mysqli_num_rows($execSelecionaDeslike);
?>
<div id="like" style="padding-right: 10px;">
<form method="POST" action="" style="display: flex;flex-direction: row;">
<button type="submit" name="like" value="<?php echo($idComentarioLinha);?>" style="background-color: #44bd32;padding: 3px;border-radius: 5px;color: #fff;margin-right: 5px;"><i class="fas fa-thumbs-up"></i> <?php echo "$contaLike";?></button>
<button type="submit" name="deslike" value="<?php echo($idComentarioLinha);?>" style="background-color: #eb2f06;padding: 3px;border-radius: 5px;color: #fff;margin-right: 5px;"><i class="fas fa-thumbs-down"></i> <?php echo "$contaDeslike";?></button>
</form>
<?php
if(isset($_POST['like'])){
$i++;
$like = $_POST['like'];
echo "$like";
var_dump($like);
$likes = "INSERT INTO likes (idcomentario) VALUES ('$like')";
$execlikes = mysqli_query($conexaoBanco, $likes);
}
if(isset($_POST['deslike'])){
$deslike = $_POST['deslike'];
$deslikes = "INSERT INTO deslike (idcomentario) VALUES ('$deslike')";
$exedeslikes = mysqli_query($conexaoBanco,$deslikes);
}
?>