Jump to content

php form - checkbox foreach


alapimba

Recommended Posts

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:

 

<?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)); ?>

 

....
foreach($_POST['check'] as $value) {

$check_msg .= "$value\n";

}

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers = "From: " . $_POST['nome'] . " <" . $_POST['email'] . ">\r\n";

$body = "From: $nome\nE-Mail: $email\nMorada: $morada\nCodigo Postal: $cod1-$cod2 $localidade\nTelefone: $telefone\nFax: $fax\nEmpresa: $empresa\nNumero de Contribuinte: $contribuinte\n\nManuais Encomendados:\n$check_msg";

Link to comment
https://forums.phpfreaks.com/topic/143008-php-form-checkbox-foreach/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.