saragoth Posted February 18, 2010 Share Posted February 18, 2010 Ok I'm new to this obviously, I'm trying to wrap my mind around how to display a check mark when I do my query page. What I'm trying to do is have staff fill out a form, there are check boxes on this form.. <td><form name="form1" action="insert.php" method="post"> <input type="checkbox" name="fac_trans_switch_dca_day" id="fac_trans_switch_dca_day"> <input type="checkbox" name="fac_ups_dca_day" id="fac_ups_dca_day"> in the insert.php here is my INSERT stuff $sql="INSERT INTO facility (fac_trans_switch_dca_day, fac_ups_dca_day) VALUES ('$_POST[fac_trans_switch_dca_day]', '$_POST[fac_ups_dca_day]')"; each of these are in the mysql db as TINYINT(1) The form works, I can fill it out and it goes through and I see the record but checkboxes have a value of 0 regardless if they are checked or not. Looking for a little direction here and all I've gotten so far in my search is "use bit" and "don't use bit use tinyint(1)" really about to lose my mind! =( thanks, Jeremy Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 18, 2010 Share Posted February 18, 2010 <td><form name="form1" action="insert.php" method="post"> <input type="checkbox" name="fac_trans_switch_dca_day" id="fac_trans_switch_dca_day" value="true" /> <input type="checkbox" name="fac_ups_dca_day" id="fac_ups_dca_day" value="true" /> $t = 'fac_trans_switch_dca_day'; $fac_trans_switch_dca_day = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_ups_dca_day'; $fac_ups_dca_day = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $sql="INSERT INTO facility (fac_trans_switch_dca_day, fac_ups_dca_day) VALUES ( {$fac_trans_switch_dca_day}, {$fac_ups_dca_day} )"; Quote Link to comment Share on other sites More sharing options...
saragoth Posted February 22, 2010 Author Share Posted February 22, 2010 <td><form name="form1" action="insert.php" method="post"> <input type="checkbox" name="fac_trans_switch_dca_day" id="fac_trans_switch_dca_day" value="true" /> <input type="checkbox" name="fac_ups_dca_day" id="fac_ups_dca_day" value="true" /> $t = 'fac_trans_switch_dca_day'; $fac_trans_switch_dca_day = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $t = 'fac_ups_dca_day'; $fac_ups_dca_day = array_key_exists( $t, $_POST ) && $_POST[$t] === 'true' ? 1 : 0; $sql="INSERT INTO facility (fac_trans_switch_dca_day, fac_ups_dca_day) VALUES ( {$fac_trans_switch_dca_day}, {$fac_ups_dca_day} )"; You are the friggen man! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.