# Php form - checkbox foreach

**URL:** https://forum.kirupa.com/t/php-form-checkbox-foreach/280700
**Category:** Uncategorized
**Created:** [January 30, 2009, 3:01pm UTC](https://forum.kirupa.com/t/php-form-checkbox-foreach/280700 "2009-01-30T15:01:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alapimba](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@alapimba](https://forum.kirupa.com/u/alapimba)
#### Post date: [January 30, 2009, 3:01pm UTC](https://forum.kirupa.com/t/php-form-checkbox-foreach/280700/1 "2009-01-30T15:01:26Z")

</div>

Hello,  
I need to design a form to order some items. The items list come from a mySQL database.  
And for each item i need to have one text field (to choose the quantity and i guess a checkbox so the user can choose what they want)  
This is sounds confusing even for me ???  
Anyone can tell me whats the best way to do this? i have the list of items and i need to let the user choose which ones they want and how many for each one.  
I had only a checkox and the code was like this:

```auto
<?php do { ?><tr>
 
                <td align="right"><label>
                  <input name="check[]" type="checkbox" id="checkbox" value="<?php echo $row_rs_manuais['titulo']; ?>" />
                </label></td>
                <td><?php echo $row_rs_manuais['titulo']; ?></td>
 
            </tr> <?php } while ($row_rs_manuais = mysql_fetch_assoc($rs_manuais)); ?>

```

```auto

....
foreach($_POST['check'] as $value) {
$check_msg .= "$value
";
}
$headers = "MIME-Version: 1.0
";
$headers .= "Content-type: text/html; charset=iso-8859-1
";
$headers = "From: " . $_POST['nome'] . " <" . $_POST['email'] . ">
";
$body = "From: $nome
E-Mail: $email
Morada: $morada
Codigo Postal: $cod1-$cod2 $localidade
Telefone: $telefone
Fax: $fax
Empresa: $empresa
Numero de Contribuinte: $contribuinte

Manuais Encomendados:
$check_msg";

```
