0
I looked at some questions here on the site, but could not understand well. I have several checkboxes like this:
<td>
<label class="ls-label-text">
<input type="checkbox" name="adicional" value="L. Ninho" id="2.00">
L. Ninho
</label>
</td>
<td>
<label class="ls-label-text">
<input type="checkbox" name="adicional" value="Kit Kat" id="2.50">
Kit Kat
</label>
</td>
<td>
<label class="ls-label-text">
<input type="checkbox" name="adicional" value="Confete" id="2.00">
Confete
</label>
</td>
Inside a form, and I send this data to the database, only when I send it, it only sends one checkbox, it does not send all selected.
My code of action that’s the one:
<?php
include "../../lib/inc_con.php";
session_start();
$mesa = $_POST['mesa'];
$tamanho = $_POST['tamanho'];
$quantidade = $_POST['qtd'];
$adicional = $_POST['adicional'];
$hiddentotal = $_POST['hiddentotal'];
$data = date('Y-m-d H:i:s');
$produto_id1 = $_POST['produto_id1'];
$atendente_id = $_SESSION['id'];
$sql = mysql_query("INSERT INTO pedidos (mesa, tamanho, qtd, adicional, hiddentotal, data, produto_id1, atendente_id) values ('$mesa', '$tamanho', '$quantidade', '$adicional', '$hiddentotal', '$data', '$produto_id1', '$atendente_id')") or die (mysql_error());
?>
Hi Alfredo, you commented on Action but forgot to post it. Could you put as you are recovering it, please? By the way, the browser submits all checkboxes as the same name in one, but separated as if they were an array. Post Action and I’ll show you how to get it right.
– Leonardo Costa
Look at this reply or that other
– rray
If you can have more than one
adicional
please do not record in a column the values separated by comma, nothingimplode/explode
. Have you thought about how you’re gonna check out this fruit salad?– rray
Read this: http://answall.com/questions/579/por-que-n%C3%A3o-devo-usar-fun%C3%A7%C3%B5es-do-tipo-mysql
– Ivan Ferrer
We are not a forum :) http://answall.com/posts/95582/revisions
– Guilherme Nascimento