Storing Checkbox Array Data in individual variables
Another simple one from me:
I have a form which features a checkbox section called:
name = "cat[]"
from which i am collecting answers with
$cat = $_POST ['cat'];
Now I can find out what or how many options were submitted and e开发者_运维技巧cho their values with
foreach ($cat as $item) echo "$item";
But what i want to do is store each returned value in an individual variable so i can add them individually to my table in MySql.
can anyone help me do this? Or am i going about things in a backwards way (probably)?
As always, any of your help is appreciated.
Thanks
foreach ($cat as $item) {
$query = "INSERT into `table_name` (`col_name`) VALUES ('$item');";
//do something with $query
}
精彩评论