lundi 29 mars 2021

checkbox value id not getting

I tried to store my checkbox value ID to database but i am getting error count(): Parameter must be an array or an object that implements Countable in. please anyone to help me figure out my problem this is what I am trying to

The HTML:

<input type="checkbox" name="chk1[ ]" value="<?php echo $rows['AMOUNT'] .' - '. $rows['ID'] .' ';?>">&nbsp<?php echo $rows['DESCRIPTION'];?></input>

PHP:

<?php
if(isset($_POST['Save'])){
    
    $checkbox = $_POST['chk1'];
    $check = implode(", AND ", $checkbox);
    $value = explode(", AND ", $check);
    $AMOUNT = trim($value[0]);
    $FEE_ID = trim($value[1]);
    
for($i=0;$i<count($FEE_ID);$i++){
$stmt = $conn->prepare("INSERT INTO fee_checked (FEE_ID) VALUES (?)");
$stmt->bind_param("i",  $FEE_ID[$i]);
$stmt->execute();
}
}
?>

Please Any help would be greatly appreciated. Thanks ahead of time!




Aucun commentaire:

Enregistrer un commentaire