Reputation: 891
<input type='checkbox' id='checkbox-" . $counter ."' class='mdl-checkbox__input' name='product[]' value='$counter'>
for some reason, when I run the form with this name for this input, it won't run the PHP script, it won't even run the beginning of the script.
Is there some reason this isn't working? am I doing it wrong? I thought this is the actual way this would work.
[Edit] this is the actual full script in the form:
foreach($producten as $row)
{
echo("
<label class='mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect' for='checkbox-" . $counter ."'>
<input type='checkbox' id='checkbox-" . $counter ."' class='mdl-checkbox__input' name='product[]' value='$counter'>
<span class='mdl-checkbox__label'>" . $row['productcode'] . ' ' . $row['categorie'] . ' ' . $row['merk'] . ' ' . $row['type'] . ' ' . $row['cpu'] . ' ' . $row['ram'] . ' ' . $row['os'] . ' ' . $row['hdd'] . ' ' ."</span>
</label>
");
$counter++;
}
Upvotes: 0
Views: 1400
Reputation: 739
.
I have checked with below code as related your code. It's working with Checkbox array. I hope it's will help you. All the best.
<form action="#" method="POST">
<?php
$producten = array('1a','2b','3c','4d');
$counter = 1;
foreach($producten as $row)
{
echo("
<input type='checkbox' id='checkbox-" . $counter ."' class='mdl-checkbox__input' name='product[]' value='$row'> <label class='mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect' for='checkbox-" . $counter ."'> $row </label><br>
");
$counter++;
}
?>
<input type="submit" name="submit" value="Submit">
</form>
<?php echo "<pre>"; print_r($_REQUEST); ?>
Output:
Array
( [product] => Array ( [0] => 1a 1 => 2b [2] => 3c [3] => 4d ) )
Upvotes: 2