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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.