MySQL PHP Mulitple insert
Posted: Sat Jan 27, 2007 9:50 pm
Hi All,
I have a form that 'can' have many rows of input. Can anyone suggest a way to input each 'Section' one after the other?
Until I can work out how to dynamically make new rows appear I will use 10 rows of input.
The code below enters the 'last' row of data 10 times. If I move the 'mysql_query' statement outside of the loop the 'last' row is entered once.
Any pointers?
Ta, Will./
I have a form that 'can' have many rows of input. Can anyone suggest a way to input each 'Section' one after the other?
Until I can work out how to dynamically make new rows appear I will use 10 rows of input.
The code below enters the 'last' row of data 10 times. If I move the 'mysql_query' statement outside of the loop the 'last' row is entered once.
Any pointers?
Ta, Will./
Code: Select all
// Input Section 1 //
echo "<tr><td width=100px valign=top><select name=\"driverType\">\n
<option value=\"delivery\">Delivery</option>\n
<option value=\"return\">Return</option>\n</select></td>";
echo "<td width=150px>".showProduct()."</td>";
echo "<td width=75px valign=top>
<input type=\"text\" name=\"amount\" size=\"2\"></input></td></tr>";
// Input Section 2 //
echo "<tr><td width=100px valign=top><select name=\"driverType\">\n
<option value=\"delivery\">Delivery</option>\n
<option value=\"return\">Return</option>\n</select></td>";
echo "<td width=150px>".showProduct()."</td>";
echo "<td width=75px valign=top>
<input type=\"text\" name=\"amount\" size=\"2\"></input></td></tr>";
for ($x = 1; $x <= 10; $x++) {
$sql_add_invoice_items = "INSERT INTO invoice_items VALUES('','$prod_name', '$amount', '$invoice_increment', '$price', '$cooked', '$date', '$wholesale', '$gst', '$wholesale_price', '$wholesale_gst')";
mysql_query($sql_add_invoice_items) or die(mysql_error());
}