Why can’t the data in mysql not updated when I use checkbox, I already tried removing the input type hidden, but still didn’t work. I think the problem must be in this part, because when I try to add records and check all of the checkboxes.
Then I will try to update it. By removing the checks in the other entry. The data is updated. the checks that are removed are also reflected in the database, but when I try to add checks on them again using the update module, it will not be updated. Please help, I’m just a beginner.
<td><input name="stats3" type="checkbox" id="sh"
value="<?php echo $row["STAT3"]; ?>" <?php echo $row["STAT3"] ? 'checked="checked"' : ''; ?> >Stockholder</td>
When you have a checkbox and you tick it, you get a key/value pair returned in the post to the server.
When the checkbox is not checked, it actually doesn’t come back in the post (you can check this using Firebug, or by print_r($_POST)
This could be causing your problem.
You can either use:
Or another easy solution is to have a select list with yes and no as options, which will always give you a value back – otherwise you need to set and unset the value based on the presence of the tick box in the post.