I want to update a table from multiple checkboxes with dynamic fields.
I built the checkboxes with the below code:
<div class="form-horizontal" style="margin-right: 35px; margin-left: 0px;">
<div class="form-group">
<? $i = 0;
foreach ($row_specifics as $title => $value) { ?>
<label class="control-label col-lg-2"><?= $title ?></label>
<div class="col-lg-1" style="padding-right: 5px; padding-left: 0px;">
<div class="make-switch switch-small" data-on="success" data-off="danger">
<input id="<?= $title ?>" name="<?= $title ?>" type="checkbox" <?= $value=='on' ? 'checked' : ''?> />
</div>
</div>
<? $i++;
if($i % 4 == 0) { ?>
</div>
<div class="form-group">
<?}
}?>
</div>
So i get this as i want it.

When i submit my form i run a function that gets all the fields from the table specifics and tries to update the table with the changes from the form (checkbox)
foreach ($row_specifics as $title => $value) {
$valueToInsert = ( isset($_REQUEST[$title]) ) ? $value : null;
if( $valueToInsert ) {
$query = mysql_query("UPDATE `specifics` SET $title = '{$valueToInsert}' WHERE `car_id`= $id");
}
}
- When i change the form to
POSTand i submit test changes, nothing happens. - When i change the form to
GETand i submit test changes, i get only theonvalues in URL query.
I tried to echo the $title and $valueToInsert inside if to check the problem (in POST) but i get only three values [ABS on / ESP on / Immobilizer on].
REQUEST: I want to update the table correctly, when someone change the checkbox options. This form and checkbox is at the Edit Panel of an administration page and the user edit the specifications of a record in table.
valueattributes. - Barmarchecked attribto on . If so, it's possible over there to be the problem - Cristian Bitoivalueis sent in the submit, not in view of the checkboxes - John Priestakos