i'm new to php and i have this php script, but for some reason its not working. What i want is when the checkbox is checked, the value of the specific table will increase by 1 after i click the 'submit' button.
php:
<?php
if(isset($_POST['submit'])){//to run PHP script on submit
if(!empty($_POST['check_list'])){
foreach($_POST['check_list'] as $selected){
$sql = "UPDATE users SET marks = marks + 2 WHERE id = $selected";
mysqli_query($sql);
}
}
}
?>
and here is my table code which collect the data:
<form action="#" method="post">
<table class='default'>
<tr>
<th>Delete</th><th>Username</th><th>Email</th><th>First Name</th><th>Last Name</th><th>Join Date</th><th>Last Sign In</th><th>Logins</th>
</tr>
<tbody>
<?php foreach ($userData as $v1) { ?>
<tr>
<td><input type="checkbox" name="check_list[]" value="<?=$v1->id?>" /></td>
<td><?=$v1->username?></td>
<td><?=$v1->fname?></td>
<td><?=$v1->lname?></td>
<td><?=$v1->marks?></td>
<td><?=$v1->join_date?></td>
</tr>
<?php } ?>
</tbody>
</table>
<input type="submit" name="submit" value="Submit"/>
</form>
where am i doing wrong?