Wow, that's not at all what you asked for in your original post.
Edit: Oh, okay I think I see where you were coming from originally. But, no, it wasn't very clear.
The first thing that you need to do is make sure that the data in your products table is actually sent to the server when the form is submitted. To do this you need to include the inputs (ie. the checkboxes and quantity textfields) in the <form> tag. Based on your current HTML layout, if you move the <form> opening tag to just before <div id="ordertablewrapper"> I think this ought to work fine.
The next thing that you need to do is assign names to each of your inputs. For this I recommend using the array feature of names. That is you can submit multiple inputs under the same name, and it is treated as an array in PHP.
In this case you might want to use something like the following:
HTML Code:
Cow Mat: <input type="hidden" name="product[]" value="Cow Mat" /><input type="checkbox" name="order[]" /> (Quantity: <input type="text" name="quantity[]" />)
And the only thing that will change between products is the value of the hidden input, product[].
What we have here is three fields: the first is a hidden field which will send back the name of the product to the server, the second is a checkbox that will indicate in the submission that the product is to be ordered, and a third indicating the quantity of the product that ought to be ordered.
In PHP, when the form is submitted, you will have only three extra variables in $_POST: $_POST['product'], $_POST['order'] and $_POST['quantity']. The trick is that each of these variables is an array containing multiple pieces of information.
So, when it comes to reading the information you can do so like this:
PHP Code:
<?php
foreach ($_POST['product'] as $k => $product)
{
$ordered = isset($_POST['order'][$k]);
$quantity = $_POST['quantity'][$k];
if ($ordered)
{
echo "Ordered $quantity $product(s). ";
}
else
{
echo "Ordered no $product(s). ";
}
}
?>
Note here that we have explicitly typed the name of the product into the form and we are using that as our identifier. On more complex shopping systems what is actually put here is the ID number of the product. When the form is submitted information about the product, such as the name and cost, is taken from a database row selected based on the ID number. I felt that since your form is hard-coded in HTML that this was a neater way of handling the data.
Hope that helps
