Jump to content

Linking Checkbox value to a table record in PHP And Changing Values


TecTao

Recommended Posts

I posted a topic earlier and there was confusion as to what I could not work out.

 

I am able to display the checkbox, either checked or unchecked depending of the value or 1 or 0 in the obcDisplay field.

<input type="checkbox" name="obcDisplay" value="<?=$r['obcDisplay'] ?>" <?=($r['obcDisplay']) ? 'checked="checked"' : ''; ?>/>

I am trying to update the DB table by the checkbox.  If the checkbox is checked (obcDisplay = 1) and I uncheck the box and submit, I want the table updated so that obcDisplay now equals 0.  When the form is displayed, the checkbox is now uncheck (obcDisplay = 0).  Now I check the box and submit and the update changes the field from 0 to 1.

 

I can display the checkbox as checked or unchecked by the DB field obcDisplay being either 0 or 1.  It is changing the value where I am having the problem.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.