[PHP] Re: checkbox question

2002-09-10 Thread B.C. Lance

if you can't use [] for the checkbox, the only way out is to have unique 
name for each checkbox.

otherwise, php will always be returning the value of the last checked 
checkbox if all checkboxes share the same name without the [].

--lance

Alex Shi wrote:
 How to ontain data from a group of checkbox using same name?
 For example, in a form there're 6 checkboxes and all named as
 Interesting_Area. I know if put a pairs of square brackets at the
 end of the name then in php all the values of them can be ontained.
 However, for some reason I cannot use square brackets. Please
 help me out if anyone know how to do the trick. THanks!
 
 Alex
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: checkbox question

2002-09-10 Thread Craig Donnelly

This will work:
  http://www.php.net/array_merge

Call your checkboxes like so:

a.php
==
 form action=b.php method=post
 input type=checkbox name=a1 value=Abr
 input type=checkbox name=a2 value=Bbr
 input type=checkbox name=a3 value=Cbr
 input type=checkbox name=a4 value=Dbr
 input type=checkbox name=a5 value=Ebr
 input type=checkbox name=a6 value=Fbr
 input type=submit name=submit value=SUBMIT
/form
==

then post it to the desired page and do something like this:

b.php
==
?php

$foo =
array_merge($_POST['a1'],$_POST['a2'],$_POST['a3'],$_POST['a4'],$_POST['a5']
,$_POST['a6']);

 echo $foo; // Returns an array

 echo pre;
 print_r($foo);  // Look whats in the array
 echo /pre;
?
==


Best of luck,

Craig




B.C. Lance [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 if you can't use [] for the checkbox, the only way out is to have unique
 name for each checkbox.

 otherwise, php will always be returning the value of the last checked
 checkbox if all checkboxes share the same name without the [].

 --lance

 Alex Shi wrote:
  How to ontain data from a group of checkbox using same name?
  For example, in a form there're 6 checkboxes and all named as
  Interesting_Area. I know if put a pairs of square brackets at the
  end of the name then in php all the values of them can be ontained.
  However, for some reason I cannot use square brackets. Please
  help me out if anyone know how to do the trick. THanks!
 
  Alex
 
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: checkbox question

2002-09-09 Thread Craig Donnelly

Why cant you use square brackets??

call all your checkboxes the following:

interesting_area[]

Then post it to whatever page, now all the checkboxes that were checked are
held in a array (interesting_area)

To see what is contained in the array, do the following:

?php
echo pre;
print_r($_POST[interesting_area]);
echo /pre;
?

From here it depends on what you want to do with the data..

You can loop through the array, using for(), foreach() or while(), or
alternatively write a function to manipulate the data.

Hope that helps,

Craig

Alex Shi [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 How to ontain data from a group of checkbox using same name?
 For example, in a form there're 6 checkboxes and all named as
 Interesting_Area. I know if put a pairs of square brackets at the
 end of the name then in php all the values of them can be ontained.
 However, for some reason I cannot use square brackets. Please
 help me out if anyone know how to do the trick. THanks!

 Alex


 --
 ---
 TrafficBuilder Network:
 http://www.bestadv.net/index.cfm?ref=7029




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: checkbox question

2002-09-08 Thread Rodrigo Dominguez

Why you can't use square brackets?
Alex Shi [EMAIL PROTECTED] escribió en el mensaje
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 How to ontain data from a group of checkbox using same name?
 For example, in a form there're 6 checkboxes and all named as
 Interesting_Area. I know if put a pairs of square brackets at the
 end of the name then in php all the values of them can be ontained.
 However, for some reason I cannot use square brackets. Please
 help me out if anyone know how to do the trick. THanks!

 Alex


 --
 ---
 TrafficBuilder Network:
 http://www.bestadv.net/index.cfm?ref=7029




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php