0

Hi All,


i am developing in which user can search by various features.

i have given a list of feature using checkboxes like.

<input type="checkbox" name="feature" value="Air Conditioning" />Air Conditioning

<input type="checkbox" name="feature" value="CD Player" />CD Player

<input type="checkbox" name="feature" value="Rumpus Room" />Rumpus Room

i am using post method in the form

i am passing all the values to another page where search will display.

search.php?feature=AirConditioning&feature=CdPlayer

now i want to get the value of all the features at once

i want to make feature an array.

Could anybody help me i could i make it possible

thanks.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by br1dil
0

Hello Rahul,

To get form values in array, you just have to write your form names like this (i'm using your example):

<input type="checkbox" name="feature[]" value="Air Conditioning" />Air Conditioning
<input type="checkbox" name="feature[]" value="CD Player" />CD Player
<input type="checkbox" name="feature[]" value="Rumpus Room" />Rumpus Room

Add [] at the end of your variable's name and that's it.
Now in your PHP script, you will have an array like this:

Array ( [0] => Air Conditioning [1] => CD Player [2] => Rumpus Room)

I hope it helps, have a good day.

Bruno

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.