PDA

View Full Version : echoing multiple check boxes


tony09uk
03-23-2012, 01:45 PM
I have created some checkboxes and would like to echo the ones the user selects.

I have created this:

--------------------------------------------------------------------------

page one:

Bike<input type="checkbox" name="vehicle" value="Bike" /><br/>
Car<input type="checkbox" name="vehicle" value="Car" /><br/>
bus<input type="checkbox" name="vehicle" value="bus" /><br/>
train<input type="checkbox" name="vehicle" value="train" /><br/>
plane<input type="checkbox" name="vehicle" value="plane" /><br/>
other<input type="checkbox" name="vehicle" value="other" /><br/>

page two - (processing):

$vehicle = $_POST['vehicle'];

echo $vehicles

--------------------------------------------------------------------------

It only echo's the last box selected. I have had a play with different loops and feel they are the answer, but I am looking for some guidance on how to create a loop that will achieve my goal.....so far all I have achieved is error messages

edbr
03-24-2012, 03:26 AM
vehicle with multiple select becomes an array do the form should be
Bike<input type="checkbox" name="vehicle[]" value="Bike" />