Possible Duplicate:
Get $_POST from multiple checkboxes
I'm a little new to web development and this is a problem (having completely stumped me) I feel has a simple solution, so I won't beat around the bush trying to figure it out myself. I will also focus on the most important bits.
I have some PHP code that is outputting a table, a form and a checkbox next to each row. Each one of the checkboxes looks like this:
<input type="checkbox" name="data_id" value="1">
<input type="checkbox" name="data_id" value="2">
<input type="checkbox" name="data_id" value="3">
As well as the submit button:
<input type='submit' name='Submit' value='Submit'/>
Standard form setup, nothing special.
I'd like to get the checked items in an array, however when I retrieve the data from the form using $_POST:
if($_POST['data_id'])
{
var_dump($_POST['data_id']); //returns string
print_r($_POST['data_id']); //shows only one checkbox value
};
What exactly am I doing wrong that the variable is not being returned an array?