samedi 7 juillet 2018

How to insert multiple values of checkbox in multiple rows with same id in database

Here is my html code

    <form action="view.php" method="post" id="form">
    <p>checkbox: <input type="checkbox" name="check[]" value="INCOMETAX" />INCOMETAX</p>

    <p>checkbox: <input type="checkbox" name="check[]" value="GST" />GST</p>

    <p>checkbox: <input type="checkbox" name="check[]" value="VAT" />VAT</p>

My php code is here

if ( isset($_POST['check']) ) {
        $checkbox1=$_POST['check'];  

        $chk = "";  
        foreach($checkbox1 as $chk1)  
        {  
         $chk .= $chk1 .",";

                   $sql = "INSERT INTO value (service) VALUES ('$chk')";

        }

The code is work proper but I want to store value in new row with same id ,rightnow the multiple values from checkbox is stored like INCOMETAX,GST,VAT

how I store INCOMEtax in first row,GST in second row and VAT in third row with same id 1




Aucun commentaire:

Enregistrer un commentaire