I have asked this before here, but I'm not sure, if the question was clear enough, or right. So now I ask again, the solution I have is not 100% right!
I have a form and I submit it, there is a table in it. Each line of the table has a checkbox that you can check for ordering a product, a select field for a charge for the product and of course the price (in a select field, so I have a value for the price).
The goal to achieve is to have blocks in the mail, like this (below):
product: greek salad xl
quantity: 4pcs.
price: 5.50$
product: tomatos
quantity: 8pcs.
price: 2.50$
....
so I have this, but the price is always taken from the first element, so, if I chose the second and third product: the price is taken from the first. The quantity is taken from the first - it is shifted one.
What can I do?
This is the (simple) foreach PHP setup that I have tried (and many other variations):
$product = $_POST['bestellung']; --> this is the checkbox that is correct!
$quantity = $_POST['menge']; --> always shifted...
$price = $_POST['liq_preis']; --> always shifted...
foreach( $product as $key => $item ) {
$bestell_tab .= "\n\nProdukt: $item \n\nStueckzahl: ".$quantity[$key]." \n\nPreis: ".$price[$key].";
}
(the $bestell_tab I put in the PHP mail for submit ...)
If somebody can help a php-greenhorn with a "simple" solution, it would be great!
Here HTML Markup:
<select class="kat-preis" name="liq_preis[]"><option value="10.00">10.00</option></select>
<select class="1-100" name="menge[]"><option value="1">1</option><option value="2">2</option></select>
<input type="checkbox" name="bestellung[]" value="expl-tomatos">
Edit
array(14) {
["tablepress-23_length"]=>
string(2) "10"
["menge"]=>
array(6) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "2"
[3]=>
string(1) "2"
[4]=>
string(1) "2"
[5]=>
string(1) "2"
}
["liq_preis"]=>
array(6) {
[0]=>
string(4) "1.00"
[1]=>
string(4) "2.00"
[2]=>
string(4) "3.00"
[3]=>
string(4) "4.00"
[4]=>
string(4) "5.00"
[5]=>
string(4) "6.00"
}
["bestellung"]=>
array(5) {
[0]=>
string(9) "tomatos109"
[1]=>
string(9) "tomatos111"
[2]=>
string(9) "tomatos116"
[3]=>
string(9) "tomatos118"
[4]=>
string(9) "tomatos209"
}
In this, I have clicked on the 2nd Product. The first is empty, but the value isn't right. It is only for the product name "bestellung" right
Edit
<td class="column-1">51234</td><td class="column-2">goodchoice</td><td class="column-3">tomatos from Spain</td><td class="column-4"><select class="kat-preis" name="liq_preis[]"><option value="1.00">10.00</option></select></td><td class="column-5">1.00 CHF</td><td class="column-6"><select class="1-100" name="menge[]"><option value="1">1</option><option value="2">2</option></select></td><td class="column-7"><input type="checkbox" name="bestellung[]" value="51234"> </td>
[]on your name attribute in order to send arrays to the server