I'm creating a forum where people can vote on posts. The vote is called 'consents'.

```
<?php
$postshow = "SELECT * FROM ideas_1 ORDER BY consents DESC LIMIT 10";
$done = mysqli_query($conn, $postshow);
//$show = mysqli_fetch_assoc($done);

while ($show = mysqli_fetch_assoc($done)) {
    echo"<div class = 'comments'>";
    echo"<br>";   
    echo"<br>";
    echo $show['post'];
    echo"<br>";
    echo"<p class = 'counter'>";
    echo $show['consents'];
    echo"</p>";
    echo"<br>";
    $postid = $show['postid'];
    $userid = $show['userid'];
    $consents = $show['consents'];
      $asd = "SELECT * FROM consents WHERE dept = 'ideas' and task = '1' and postid = '$postid' and voterid = '$id'";
      $doit = mysqli_query($conn, $asd);
      $exist = mysqli_num_rows($doit);
      if ($exist == 0){
    echo"<button id = \"consents$postid\">Consent This</button>";
      }
    echo"</div>";

}
?>
<script>
    var posterid = "<?php echo $userid;?>"
    var postid = "<?php echo $postid;?>"
    var voterid = "<?php echo $id;?>"
    var consents = "<?php echo $consents;?>"

$(document).ready(function () {   
   $('#consents' + postid).click(function(){
    $(this).hide();
    $.post ("consentsideas.php", {
        dept: "ideas",
        task: "1",
        postid: postid,
        voterid: voterid,
        consents: consents,
        posterid: posterid
    });
    $(".counter").html(++consents);
   });
   $(".answer").mousedown(function(){
            $(".post_answer").show();
            });
   $(document).click(function(event) { 
    if(!$(event.target).closest('.post_answer').length) {
        if($('.post_answer').is(":visible")) {
            $('.post_answer').hide();
        }
    }        
}); 
  $(".post_answer").click(function(){
    var answer = $(".answer").val();
    $.post ("answerideas.php", {
        answer: answer,
        id: voterid
            });
    $(".answer").val('');
    });
}
  ); 
</script>

```

But any button looped by the while loop, when clicked, only updates the CONSENTS counter for the last iteration of the while loop. 
As you can see, I've made the button's id unique(I hope I did that correctly). So could anyone tell me where's the problem?