jasonhardwick Posted May 17, 2008 Share Posted May 17, 2008 ok i have a checkbox that has a "Private" checked value and a " " unchecked value when i pull the checkbox information back into an edit page i cannot uncheck the box and save the new value into my sql any ideas? <input name="e_private" type="checkbox" id="e_private" value="Private"<?php if (isset($row['e_private']) && $row['e_private']=="Private"){echo 'checked="checked"' ;}else{ echo " ";} ?> /> Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/ Share on other sites More sharing options...
BlueSkyIS Posted May 17, 2008 Share Posted May 17, 2008 you need a space before checked, and no need for the else since it does nothign: <input name="e_private" type="checkbox" id="e_private" value="Private" <?php if (isset($row['e_private']) && $row['e_private']=="Private"){echo 'checked="checked"';} ?> /> Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/#findComment-543754 Share on other sites More sharing options...
jasonhardwick Posted May 17, 2008 Author Share Posted May 17, 2008 Thanks, but no luck with that code still wont update my database??? any other ideas Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/#findComment-543787 Share on other sites More sharing options...
Barand Posted May 17, 2008 Share Posted May 17, 2008 Only checked checkbox values are posted, so you need something like $private = isset($_POST['e_private'] ? 'Private' : ''; Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/#findComment-543849 Share on other sites More sharing options...
jasonhardwick Posted May 18, 2008 Author Share Posted May 18, 2008 thanks. but how would i incorporate that into my code? Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/#findComment-543869 Share on other sites More sharing options...
Barand Posted May 18, 2008 Share Posted May 18, 2008 Sorry, clairvoyance isn't in my skillset. Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/#findComment-543870 Share on other sites More sharing options...
jasonhardwick Posted May 18, 2008 Author Share Posted May 18, 2008 sorry just wondering what the new checkbox input code would be, what would be the best way to use the "$private"? <input name="e_private" type="checkbox" id="e_private" value="Private" <?php $private = isset($_POST['e_private'] ? 'Private' : ''; if (isset($row['e_private']) && $row['e_private']=="Private"){ echo 'checked="checked"'; } ?> /> Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/#findComment-543881 Share on other sites More sharing options...
jasonhardwick Posted May 18, 2008 Author Share Posted May 18, 2008 Ok just decided to use a list menu insted of a checkbox... not ideal but it gets the job done. Thanks everyone Link to comment https://forums.phpfreaks.com/topic/106090-editing-a-checkbox/#findComment-543885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.