I'm new to PHP so this might be something obvious I missed. Im trying to make a button which increments a value in my database:
<?php
$alist = mysqli_query($conn, "SELECT * FROM `posts` ORDER BY `posts`.`id` DESC");
$results = mysqli_num_rows($alist);
if ($results > 0){
while($row = mysqli_fetch_array($alist)) {
echo $row['uid']. " says: ".$row['postText']." <button onclick=".mysqli_query($conn, "UPDATE `posts` SET `postLikes` = postLikes+1 WHERE uid = ".$row['uid'])." name='likebtn'>👍</button>".$row['postLikes']."<br>";
}
}
?>
The part that makes the button is on line 6
I just want to find how I can use the mysqli_query on button click
by the way, I already tried this: "https://stackoverflow.com/questions/3862462/php-mysql-run-query-on-button-press-click" but with no result
Thanks in advance