2010-08-14 15:03


  • loops
  • php
  • sql

I have a form that once submitted some of its result are stored in arrays, example:

(The form has multiple lines with the same input names)

<select name="product[]"> once submitted goes into $_GET['product']

if I do:

// Product ID's
foreach($_GET['product'] as $name => $prodvalue) {
print "$name : $prodvalue<br>";

the following is returned:

0 : 9

1 : 10

2 : 11

3 : 12

As well as the Product ID's I have 2 other form input structured the same way, so my question is how do I loop through each of the $_GET's ($_GET['product'], $_GET['linequantity'] and $_GET['lineprice']) to add each of them to multiple SQL table rows? Also there will be other records that need to be entered, but, these will be constant, so for instance, if 3 rows are to be added then the other records will be the same for each of the 3 rows.

Please help me, I'm goin' nuts!



The table is called: order_lines

Value => Field

$_GET['product'] => product_id

$_GET['linequantity'] => unit_price

$_GET['lineprice'] => qty

$unh => unh

There are more, but, i can work it out from there.

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享