TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-15-2007, 11:48 AM   #1 (permalink)
The Contributor
Upcoming Programmer 
 
meshi's Avatar
 
Join Date: Oct 2007
Posts: 44
Thanks: 0
meshi is on a distinguished road
Default 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?
meshi is offline  
Reply With Quote
Old 10-15-2007, 04:48 PM   #2 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

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)" 
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Old 10-16-2007, 07:25 AM   #3 (permalink)
The Contributor
Upcoming Programmer 
 
meshi's Avatar
 
Join Date: Oct 2007
Posts: 44
Thanks: 0
meshi is on a distinguished road
Default

tanx karl...ur the best
meshi is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:15 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design