View Single Post
Old 12-08-2012, 11:57 PM   PM User | #4
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
You create an array of checkboxes by appending square brackets to the end of their name - using the same name. NB only checked items will be posted, the others will just disappear - into Santa's flight path

Something like this:

Code:
<input type='checkbox' value="Product1" name='cBox[]'/>
<input type='checkbox' value="Product2" name='cBox[]'/>
<input type='checkbox' value="Product3" name='cBox[]'/>
PHP Code:
<?php
if (isset($_POST['orderID']) && !empty($_POST['orderID'])) {
    
$orderID $_POST['orderID'];
    
    if (isset(
$_POST['cBox']) && !empty($_POST['cBox'])) {
        foreach (
$_POST['cBox'] as $productID) {
            
// SQL to insert $orderID and $productID into database
        
}
    }
}
?>
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote