I have an array which include a checkbox input. The problem is when there's a not checked checkbox, the POST method does not store the value although i give it ?? 0.
I tried to check if it checked or not like other people do, but still have the problem.
$count= count($_POST["date"]) ?? 0;
for ($i = 0; $i < $count; $i++) {
$array= [$code,
$_POST['date'][$i],
$_POST['a'][$i] ?? 0,
$_POST['b'][$i] ?? 0,
$_POST['c'][$i] ?? 0,
$_POST['d'][$i] ?? 0,
$_POST['e'][$i] ?? 0,
$_POST['f'][$i] ?? 0,
$_POST['g'][$i] ?? 0,
$_POST['h'][$i] ?? 0,
$_POST['i'][$i] ?? 0,
$_POST['j'][$i] ?? 0,
$_POST['k'][$i] ?? 0,
$_POST['UP'][$i] ?? 0,
$_POST['BB'][$i] ?? 0,
$_POST['bug'][$i] ?? 0,
$_SESSION['user']
];
$arrays[] = $array;
}
The checkbox name is bug[] with value="1". When i try to click some checkbox, it counted as the first array value. Example: a b c d e f g not checked a b c d e f g checked a b c d e f g not checked a b c d e f g checked Result: a b c d e f g checked a b c d e f g checked a b c d e f g not checked a b c d e f g not checked
Aucun commentaire:
Enregistrer un commentaire