I have this code for example :
$b = "";
while ($row = mysql_fetch_array($rows)) {
if ($row['enabled'] == 1) {
$b = "checked";
} else {
$b = "":
}
echo “<\input name=’nam[$row[id]]’ type=’checkbox’ value=’$row[id]’ $b />”;
}
When I execute this code, I will get a list of checkboxes, some of them are checked and others are not.
I can use this code to get a list of checked checkboxes.
if (isset($_POST['sub'])) { //check if form has been submitted or not
$nam = $_POST['nam'];
if (!empty($nam)) {
foreach($nam as $k=>$val){
// proccess operation with checked checkboxes
}
}
I need to know how I can get list of unckecked checkboxes after submitting the form.
Thanks in advance.
If the check boxes are dynamically created this is a trivial task:
Create a naming convention. For example, lets say that each checkbox is tied to a row in the DB, each row in the DB has a primary key. You can name each checkbox based off this key:
Now when the form is submitted you can query the database to get the Id’s and process the request as follows: