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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.