OZONE Asylum
FAQ
How do I pass data from checkboxes in a form using PHP?
This page's ID:
5364
Search
QuickChanges
Forums
FAQ
Archives
Register
You are editing "How do I pass data from checkboxes in a form using PHP?"
Who can edit an FAQ?
Anyone registered may edit an FAQ.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
The trick is to make the name of the checkbox an array: [code] <input type="checkbox" name="my_check[1]" /> 1<br /> <input type="checkbox" name="my_check[2]" /> 2<br /> ETC. [/code] and then process it on the page you send the data to like: [code] if (is_array ($my_check)) { while (list ($key, $value) = each ($my_check)) { $data .= "$key, "; } } [/code] Adapt the name and who you want the data outputted and you'll be away. --------------------- Note: You can also set the values this way too (I'm not aware of any differences in performance between the 2 methods): [code] <input type="checkbox" name="my_check[]" value="1" /> 1<br /> <input type="checkbox" name="my_check[]" value="2" /> 2<br /> ETC. [/code] _________________________ [internallink=4626]Emperor[/internallink] [small][i](Added by: [url=http://www.ozoneasylum.com/cgi-bin/ubbmisc.cgi?action=getbio&UserName=Emperor]Emperor [/url] on Wed 23-Oct-2002)[/i][/small] [small][i](Edited by: [url=http://www.ozoneasylum.com/cgi-bin/ubbmisc.cgi?action=getbio&UserName=Emperor]Emperor [/url] on Fri 25-Oct-2002)[/i][/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »