English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am using multiple checkboxes for example



How do i get multiple values using the $_GET method in PHP?

I tried this:
$gender = $_GET['gender'];
$_gender = "$gender[0],$gender[1]";

But didn't work

In MySQL database i have the field called gender which is of type SET and can only have 'M','F'

2006-07-16 23:41:14 · 3 answers · asked by Manish 5 in Computers & Internet Programming & Design

Now the second trouble is that, the checkboxes are created automatically from the values coming from MySQL so i have to take the same name coz not sure how many checkboxes will be created.

2006-07-16 23:46:26 · update #1

$gender seems to have only one value which is the last one for example if user selects M and F both checkboxes, $ gender only gets F, but if use selects only M then $gender has M

2006-07-16 23:51:46 · update #2

3 answers

Use different names.

If you use the same names then you're asking for trouble - and it looks like you've got some!

2006-07-16 23:44:14 · answer #1 · answered by Anonymous · 3 3

you need to make these radio buttons instead of checkboxes if you are only going to accept one as valid. If you name them the same and make the type radio instead of checkbox only one can be checked at a time and $_GET['gender'] will have the value of the selected one.

If you want to use checkboxes with the same name in PHP you need to name them gender[] like in your next question.

2006-07-17 08:09:28 · answer #2 · answered by John J 6 · 0 0

The variable $gender variable contains a list of values of 'checked checkboxes'.So you have to split these values into an array.I think it is explode function,based on delimiter.

2006-07-17 06:47:39 · answer #3 · answered by Priyan 1 · 0 0

fedest.com, questions and answers