PHP checkbox loop with other values into database

Hello.

I have a table which includes order rows from webshop.
In the rows I have checkboxes, which tell if that row has been handled by customer.

I’m currently able to loop through the checkboxes telling me which ones of those are checked.
I want to also get values from order id’s and orderlines to tell database which row is handled.

So in the end, when user has checked his/her checkboxes, when he presses the submit button:
It gets the checkboxes from the rows that user has checked and imports that checkbox value into database where order id = order id in which customer checked and orderline = orderline in which customer checked.

How do I do this?

<input type="checkbox" name="orderid[]" value="1" />
<input type="checkbox" name="orderline1[]" value="a" />
<input type="checkbox" name="orderline1[]" value="b" />
<input type="checkbox" name="orderline1[]" value="c" />

<input type="checkbox" name="orderid[]" value="2" />
<input type="checkbox" name="orderline2[]" value="a" />
<input type="checkbox" name="orderline2[]" value="b" />
<input type="checkbox" name="orderline2[]" value="c" />

[php]if(is_array($_POST[‘orderid’])) foreach($_POST[‘orderid’] as $orderid){

$n = $orderid;
if(is_array($_POST['orderline'.$n])) foreach($_POST['orderline'.$n] as $orderline){
    // Do your magic with $orderid & $orderline
}

}[/php]

This will only process the values that have been checked for orderid.
So… how are your checkboxes setup?
1 orderid checkbox with say 3 orderline checkboxes?

Sponsor our Newsletter | Privacy Policy | Terms of Service