TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   how to make the value of checkbox 1 or 0 (http://www.talkphp.com/general/1306-how-make-value-checkbox-1-0-a.html)

meshi 10-15-2007 11:48 AM

how to make the value of checkbox 1 or 0
 
PHP Code:

$text_array3 = array(   'Decision Maker' => array ( 
                                 
'name'=> 'dm'
                                 
'text'=> 'Decision Maker',
                                
'type'=> 'checkbox',
                                
'value'=> "$row[dm]"
                          
);
                                
'Head Office' => array ( 
                                
'name'=> 'ho'
                                 
'text'=> 'Head Office'
                                
'type'=> 'checkbox',
                                
'value'=>"$row[head_office]"
                             
);
$sql=("insert into table (ho,dm)values($_POST['ho'],$_POST['dm'])" 

if i had to insert value of checkbox to mysql ,wat would i add to my code to make the value of check box 1 if check and 0 if unchecked.becoz if i check it the value is 0 and if i unchecke it the value is NULL.how would i do the 1 or 0 value?

Karl 10-15-2007 04:48 PM

The following ammendment would achieve this:

PHP Code:

$iDecisionMaker = isset($_POST['dm']) ? 0;
$iHeadOffice = isset($_POST['ho']) ? 0;
$sql=("insert into table (ho,dm)values($iHeadOffice,$iDecisionMaker)" 


meshi 10-16-2007 07:25 AM

tanx karl...ur the best


All times are GMT. The time now is 05:09 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0