I have a form with a checkbox group (same as below) and I would like that when I select the values, insert a row in the SQL table for each selected checkbox:
<form>
<input type="hidden" id="id_pedido" value="123">
<div>
<input class="uk-checkbox" type="checkbox" value="16.15"> Adicional 1
</div>
<div>
<input class="uk-checkbox" type="checkbox" value="23.75"> Adicional 2
</div>
<button id="concluir" name="concluir" class="uk-button uk-button-primary" type="submit">Concluir</button>
</form>
Then when selecting the 2 values, the MYSQL table (cv_contratos_adicional) should look like this:
id | id_pedido | valor | servico
1 | 123 | 16.15 | Adicional 1
2 | 123 | 23.75 | Adicional 2
This is what I have so far, the part of the checkbox and I need to know how to "break" the value and name of the service:
<body>
<?php
if(isset($_POST['concluir'])){
$sql = "INSERT INTO cv_contratos_adicinoais (id_pedido, valor, servico)
VALUES ('".$_POST["id_pedido"]."','".$_POST["valor"]."','".$_POST["servico"]."')";
}
?>
<form method="post">
<input type="hidden" name="id_pedido" id="id_pedido" value="123">
<div>
<input class="uk-checkbox" type="checkbox" value="16.15"> Adicional 1
</div>
<div>
<input class="uk-checkbox" type="checkbox" value="23.75"> Adicional 2
</div>
<button id="concluir" name="concluir" class="uk-button uk-button-primary" type="submit">Concluir</button>
</form>
</body>