Can't seem to get this to work. Trying to get have multiple rows inserted. No error message, insert last record only. I have also tried foreach and do while, still only getting last record. BTW, the last values in the query insert but via some variable I did not show here, but still only the last record.

Then for seconds, you are only building the query in your loop, you aren't executing it within your loop. So that means you are executing it outside of the loop, which would result in the last query to be executed only.

Two ways to solve this, one move the execution of the query into the for loop (take the hit that each query is executed individually).Or change your for loop to build multiple INSERT commands like below and leave the execution of your query outside of the for loop (notice I change = to .=, and I added a semi-colon to the end of the query.

Then for seconds, you are only building the query in your loop, you aren't executing it within your loop. So that means you are executing it outside of the loop, which would result in the last query to be executed only.

Two ways to solve this, one move the execution of the query into the for loop (take the hit that each query is executed individually).Or change your for loop to build multiple INSERT commands like below and leave the execution of your query outside of the for loop (notice I change = to .=, and I added a semi-colon to the end of the query.

Thank you for your detailed reply. After trying a number of different variations I am unable to get it to work. The results I'm sure are telling. In the first row, the result was '7', which is the quantity I entered for the last record. The next results were the first letter only of the records. This is the current variant of the code.

This is the complete [sanitized] form page. The form is created dynamically. I will include the result page below.

The form is created from a query selected rows from an individual customer table. When they execute a new table is created 'temporder', the information is inserted then queried back in the query that we have been working on.

///////below are some of the variations of the loop I have been working on, currently i have the 2 loops and getting the same results/////////////*foreach($_POST as $key => $value) {*/mysql_select_db($database_szabo, $szabo);

I'm going to take a time out here and say this;We can make this work with what you've got. It'll take a bit of complex form creation, but it can be done.I personally would recommend that you take the time to pause working on this form and head to the mySQL/databases forum with your schema; your database design is screaming 'Normalize Me!' to me.

Normalizing the database will make trying to do these inserts a LOT simpler.

I read some articles on normalization, and on the face of it it would seem this suffers, however I have sep tables for much of the information (company, products etc). In this case I used a separate query instead of a join to insert the company name.

The issue seems to be boiling down to the POST in that I can only get the last record. I have tried to insert and store in an array, but the same result of only the last result of the do while loop. I renamed "type" to "ptype" but that did not offer any different result.

This can't be that unique of an application, but it still is eluding me.

Your database screams normalize me because you're trying to insert product information into an order query; this would be redundant. The only thing an order needs to know is what was ordered (Your product's unique ID), how much was ordered, and by whom (a customer unique ID, presumably).

What you're wanting to do is not so unique, no, but the only piece of information you should need to send via post is qty, attached to a key (the product's ID)<input type='text' name="qty[<productid>]">

Thanks again, however no luck. At this point I am getting a warning and error

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\szabo\szabo-confirmation.php on line 93 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

:: Line 93 foreach($_POST['qnt'] AS $id => $qnt) {

I have added a prod_id column and <input>, works fine Each product has a unique id. Have varied your example numerous ways to use the prod_id instead of the qnt, at one point I was able to insert the last $_post.

I appreciate your time and don't really expect you to write my code for me, the why this is not working is baffling.

Thank you, with your kind help it is almost working. I may have muddied the waters a bit when I added the prod_id as the key. The qnt is now inserting as I want, the prod_id is not. Here is what I have;