SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 11th, 2002, 01:32 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
checkboxes

could somebody give me an example regarding how to handle a checkbox in a PHP form.

Like, i want to place couple of checkboxes in one of my form, for example:Studentenrolment,feepaid:
when i try to insert a student record into the students table, depending on the condition, i might check both the checkboxes or 1 or leave both empty.But, the value should be stored in the table.
how can i do this one.could somebody give me the code.

thanks in advance

Reply With Quote
  #2  
Old September 11th, 2002, 03:07 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: checkboxes

<input type="checkbox" checked name="whatever" value="whatever">

??

Reply With Quote
  #3  
Old September 11th, 2002, 03:36 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: checkboxes

Technically, according to W3C standards, that should be:
php Code:
Original - php Code
  1.  
  2. <input type="checkbox" name="whatever" value="whatever" checked="checked">

But that's just me being pedantic, lol. ;)

Reply With Quote
  #4  
Old September 11th, 2002, 08:56 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: checkboxes

I'm trying to insert records into a table.

I've these two checkboxes in a form.
Code:
<INPUT type=checkbox name="enrolment<?$stdcount?>" value="1" <? if ($enrolment== 1)echo "checked";?>>
<INPUT type=checkbox name="registration<?$stdcount?>" value="1" <? if ($registration== 1)echo "checked";?>>

When i check these 2 checkboxes and insert the record into a table, it works pretty fine.IF I LEAVE ONE OR BOTH OF THESE CHECKBOXES UNCHECKED,it produces me an error:"Conversion from string".

To avoid this error, i tried to place the following two st's before the sql insert statement.
Code:
if ($enrolment==NULL) $enrolment=0;
if ($registration==NULL) $registration=0;

But, it still gives me the error.

I feel that if the checkbox is checked, the value 1 will be inserted into the column or 0.

Does'nt it sounds meaningful??

Ps:Stdcount is an array.I guess, there is nothing to do with that.
I tried removing spaces and so on, but still, itz the same.
So, any idea behind this error??

Thanks everybody.




Reply With Quote
  #5  
Old September 11th, 2002, 09:03 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: checkboxes

Try adding in a few print_r()s and echo()s and see if that throws up anything unexpected - that's usually the best way to debug...

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > checkboxes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway