Please help.
I am trying to dynamically name my checkboxes using php. I am using POST. The problem I am running in to is $element is not working. The results of $_POST does not show any checkboxes.
Thanks in advance for the help.
foreach(array_keys($cart_array) as $element)
{
print "<input type = 'checkbox' checked name = '{$element}' />";
}
But something like
foreach(array_keys($cart_array) as $element)
{
print "<input type = 'checkbox' checked name = '$element}' />";
}
works just fine. Notice the missing { near $element}. This code would show which checkboxes are on!! The printed array would have an extra "}"
Array
(
[Tomato_and_Cheese_small] => on
[Tomato_and_Cheese_small}] => 1
[Tomato_and_Cheese_large] => on
[Tomato_and_Cheese_large}] => 1
)
ps. there are other inputs like text that get posted to $_POST just fine. The print_r($cart_array) works fine too.
print_r($cart_array)?print_r($_POST).print_r($element)inside the foreach loop, I need to be sure what it contains.