I have a php file that is receiving some checkbox values from a form. Both the checkbox name and value are set up to match an Item_Name field in a mysql table. My current attempt is below:
while($row = $items->fetch_assoc()){
if( isset($_POST[$row['Item_Name']])) {
\\ Code to perform if true, mostly echoes
}
}
//Checkbox setup:
echo "<input type='checkbox' name=" . $row['Item_Name'] . "value=" . $row['Item_Name'] . ">"
$items is the data returned by my query of the mysql table. Currently none of the echoes inside the if are triggering so I think something is wrong with my if statement, but I'm to new to php to know what is wrong exactly.
$row['Item_Name']isBags. Now PHP is looking for$_POST['bags']. Beyond that, it's up to you to debug it. Maybe tryvar_dump($_POST);?foreachfor this and making sure that the inputs have the[]multiple array brackets.array(2) { ["Applevalue=Apple"]=> string(2) "on" ["Milkvalue=Milk"]=> string(2) "on" }$row['Item_Name']are actuallyAppleandMilketc. so the problem would appear to be in the generation of thenameattributes of your checkboxes.