RynMan Posted July 4, 2009 Share Posted July 4, 2009 Hey guys I've got a form where it is returning a record from my database query. There is a field on my form that is a checkbox, and I'm trying to get it to correspond to a field in my DB that is currently a tiny integer (0 and 1's at present). Unlike the text fields, I've had no success when using the field from the array (of my query) as the "value" for the input. Does html not interpret a 0 as unchecked, and 1 as checked? How can I make it do so? Then, in addition to that, how do I then code that into my UPDATE query? Many thanks... Link to comment https://forums.phpfreaks.com/topic/164723-check-boxes-in-phpmysql/ Share on other sites More sharing options...
trq Posted July 4, 2009 Share Posted July 4, 2009 <?php echo '<input type="checkbox"' . $row['checkbox'] == 1 ? ' checked="checked">' : '>'; ?> Link to comment https://forums.phpfreaks.com/topic/164723-check-boxes-in-phpmysql/#findComment-868624 Share on other sites More sharing options...
RynMan Posted July 4, 2009 Author Share Posted July 4, 2009 <?php echo '<input type="checkbox"' . $row['checkbox'] == 1 ? ' checked="checked">' : '>'; ?> Ahh most excellent. So then, for when I wanted to run my SQL UPDATE, I'd ensure that value="1" ? Link to comment https://forums.phpfreaks.com/topic/164723-check-boxes-in-phpmysql/#findComment-868628 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.