Killersites.com Homepage Welcome Guest   |   Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | User List  | Help



Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 9912 times and has 1 reply Next Thread
Male jman
Stranger
Member's Avatar

USA
Joined: Aug 27, 2006
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
How to use PHP to process values from multiple checkboxes

Hello,
Did some research, couldn't find what I was looking for in the PHP docs... Finally found a page that mentioned you have to use a form variable named with brackets at the end [].

Like this:

<input type="checkbox" name="myvar[]" value="123"> 123
<input type="checkbox" name="myvar[]" value="abc"> abc
<input type="checkbox" name="myvar[]" value="456"> 456

then you can get the value with:

$inArr = array();

if (isset($_POST["myvar"])){
$inArr = $_POST["myvar"];
}


That's it. Thought I'd share... hopefully someone can make use of this tip.

Cheers,
-J
----------------------------------------
Small Business Resources ~ News Feeds

[Aug 27, 2006 1:49:03 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male tunerGeek
Stranger




Joined: Oct 15, 2007
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
Re: How to use PHP to process values from multiple checkboxes

Thank you, jman. I googled this topic, your post was first hit, and your very simple solution is precisely what I need!!
[Oct 15, 2007 3:34:08 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread