jeudi 15 juin 2017

PHP Undefine Index Error for Checkbox With prepare statement [duplicate]

It showing 1 notice, 1 warning & 1 error. Most probably the 1st warning is the reason for next 2. Undefined index: checkbox in

$checks = implode("','", $_POST['checkbox']);

Here is the code:

 while( $stmt->fetch()) {

    echo "<tr>";
    echo "<td>" . $accountno . "</td>";
    echo "<td>" . $accountname . "</td>";
    echo "<td>" . $brokername . "</td>";
    echo "<td>" . $revenue . "</td>";
    echo "<td>" . $status . "</td>";
    echo "<td>" . "<input name='checkbox[]' type='checkbox'  value =" .$accountno. "</td>";
    echo "</tr>";
    }

            echo "</table>";
            echo "<input type=submit value=Delete>";

            //---Data Delete code
            $checks = implode("','", $_POST['checkbox']);
            $stmt_delete_account = $mysqli->prepare("DELETE FROM 
             ***** WHERE $accountno IN $checks");
            $stmt_delete_account->bind_param('i', $accountno);  
            $stmt_delete_account->execute(); 
            $stmt_delete_account->store_result();

             $stmt->close();
             $stmt_delete_account->close();

Also, does it required to add any refresh button, can I add any simple jquery? Any coding example, in this case, will be very helpful. Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire