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

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

 

You are the friggen man!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.