Jump to content

So stuck (check marks in mysql)


saragoth

Recommended Posts

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

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/192548-so-stuck-check-marks-in-mysql/
Share on other sites

<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} )";

<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!

Archived

This topic is now archived and is 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.