Select checkbox not working

Hello all,

i have worked my head out with different solution but none have given me the desired result and so i have to seek help. I dont know why only the first check box is working. even when i select the last checkbox, the first checkbox will work.



        echo "<div class='bg-warning alert alert-warning text-center margin-top'>YOU DID NOT MAKE ANY SELECTION</div>";


            $update = $pdo->prepare("
                            UPDATE  tbl_stock
                            SET     stock_qty     = stock_qty + :stock_qty
                            WHERE   prod_id       = :prod_id

            foreach($_POST['check_list'] as $k => $prod_ids){ 
			// if i use $prod_id it gives a weird result
			// i also did ':prod_id'    => $prod_id to no avail
            $update->execute( [ 
                                ':prod_id'    => $_POST['prod_id'][$k],
                                ':stock_qty'  => $_POST['prod_qty'][$k]
                              ] );

            $cnt = $update->rowCount();


         $query = "
            UPDATE tbl_sales 
            SET  status=2, 
            date_deleted = NOW()
            WHERE trans_ref='$_SESSION[temp_trans_ref]'
            AND     prod_id       = :prod_id

            $stmt = $pdo->prepare($query);
            foreach($_POST['check_list'] as $k => $prod_name){
                                ':prod_id'    => $_POST['prod_id'][$k]

    echo "<div class='bg-success alert alert-success text-center text-white'>RECORD(S) DELETED</div>";

        echo "<div class='bg-danger alert alert-danger text-center text-white'>RECORD NOT DELETED</div>";


    <form action="" method="post">
    <div class="sales-form">

        <?php if( isset($error_msg)){ echo $error_msg; } ?>

        <table class='table'>
                    <th>Item Name</th> 
                    <th>Product Size/Type</th>
                    <th>Price (₦)</th>
                    <th>Total (₦)</th>

            $t_price = 0;
            $stmt = $pdo->query("
            SELECT * 
            FROM tbl_sales s
            LEFT JOIN  tbl_sales_total st ON s.trans_ref = st.trans_ref
            LEFT JOIN tbl_products p ON s.prod_id = p.prod_id
            WHERE s.trans_ref = '$_SESSION[temp_trans_ref]' AND s.status = 0
            while($row = $stmt->fetch(PDO::FETCH_ASSOC)){

                $prod_id        = $row['prod_id'];
                $cost_price     = $row['cost_price'];
                $prod_name      = $row['prod_name'];
                $size_type      = $row['size_type'];
                $prod_qty       = $row['prod_qty'];
                $sold_price     = $row['sold_price'];
                $total_price    = $row['total_price'];
                $t_price += $row['total_price']; 

                <td><input type='checkbox' name='check_list[]'      value='<?= $prod_id ?>' ></td>
                    <input type='text'     name='prod_id[]'       value='<?= $prod_id ?>' hidden>
                    <input type='text'     name='cost_price[]'      value='<?= $cost_price ?>' hidden>
                    <input type='text'     name='prod_name[]'       value='<?= $prod_name ?>' hidden>
                    <input type='text'     name='size_type[]'       value='<?= $size_type ?>' hidden>
                    <input type='text'     name='sold_price[]'      value='<?= $sold_price ?>' hidden>
                    <input type='text'     name='prod_qty[]'        value='<?= $prod_qty ?>' hidden>
                    <input type='text'     name='total_price[]'     value='<?= $total_price ?>' hidden>
                <td><?= $prod_name ?></td>
                <td><?= $size_type ?></td>
                <td><?= $prod_qty ?></td>
                <td><?= $sold_price ?></td>
                <td><?= $total_price ?></td>




Hi Obodo,

Is this even CakePHP code? This looks like PHP scripting.