I'm trying to update my databse with a button to set the visibility from 0 to 1. There isn't any syntax error but for some reason it doesn't change the database value. My database example: (visibility is tinyint with default 0 value)
id- name- visibility
---------------------------
1 - John - 1
---------------------------
2 - Ben - 1
---------------------------
3 - Terry - 0
---------------------------
and my php code:
<?php
$sql = "SELECT id, name, image, description, address, phone, phone2, email, job, visibility FROM cards";
$resultset = mysqli_query($conn, $sql) or die("database error:". mysqli_error($conn));
while( $record = mysqli_fetch_assoc($resultset) ) {
?>
<div class="col-md-4" <?php if ($record['visibility'] == 1) echo " style='display: none';"; ?>>I want this to be hidden here</div>
<button type="button" class="btn btn-success" name="update">Accept</button>
<?php
if(isset($_POST['update'])){
$allowed = mysqli_query($conn," UPDATE cards SET visibility = '1' WHERE id = '$id' ");
}
?>
//html stuff here
<?php }
?>