i want to update each columns acording by id, when i click on an image, without refresh all the page. my codes just update last ids column when i click each on images.
index.php:
$rzp=mysqli_query($conn,"SELECT * FROM `tbl_users_posts` WHERE uid=1");
while($rw=mysqli_fetch_assoc($rzp)){$id=$rw['id'];
echo $id;?><img id="up" src="pc3/up.png" alt=""><br>
<?php }?>
<script>
$(document).ready(function() {
var id = <?php echo $id;?>;
$(document).on("click","#up",function() {
$.ajax({
method: "POST",
url: "y2.php",
data: {id: id},
async :false
}).done(function(msg2) {
alert(msg2);
});
});
});
</script>
y2.php:
$id=$_POST['id'];
mysqli_query($conn,"UPDATE `tbl_users_posts` SET lik=lik+1 WHERE id='$id'");
thanks