aeafisme23 Posted May 20, 2008 Share Posted May 20, 2008 So i have created a form that easily adds/edits/deletes to a database except for the fact i cant update any of my checkboxes to the databases, only my input fields get updated. I just want the selected input to just update in the database under its field name/value to either be yes or no is sufficient enough. I'll give you my code and then a few of what i was thinking might be the problem, really interested in understanding this // this input addresses updates to database but the typeii checkbox does not updated and leaves the db blank <tr valign="baseline"> <td align="right" nowrap><div align="left">Address:</div></td> <td><input type="text" name="address" value="<?php echo $address ?>" size="32"></td> <td> </td> <td align="right" nowrap><div align="left">City:</div></td> <td><input type="text" name="city" value="<?php echo $city ?>" size="32"></td> </tr> <td colspan="2" align="right" nowrap> <div align="left"> <input <?php if (!(strcmp("yes","no"))) {echo "checked=\"checked\"";} ?> type="checkbox" name="typeii" value="<?php echo $typeii ?>" id="checkbox2"> Type II (Conventional Anodize)</div></td> Should i be more concerned with how each checkbox has its own id of checkbox(1,2,4,5,etc...) ex) id="checkbox2" ? and do a php echo of the vlue of checkbox2 and not my own determined name for it as typeii? <input type="checkbox" name="typeii" value="<?php echo $typeii ?>" id="checkbox2"> Link to comment https://forums.phpfreaks.com/topic/106543-solved-checkbox-insert-amp-retrieve-from-database/ Share on other sites More sharing options...
aeafisme23 Posted May 20, 2008 Author Share Posted May 20, 2008 if ($typeii != NULL) { $typeii = "YES"; } else { $typeii = "NO"; }?> and then i made input box <input type="checkbox" name="typeii" value="<?php echo $typeii ?>"> and it works, i guess i just needed to go at it harder. Thought i would at least give the community a solved so someone can benefit besides me. Link to comment https://forums.phpfreaks.com/topic/106543-solved-checkbox-insert-amp-retrieve-from-database/#findComment-546149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.