Good afternoon, dear friends, I need you to please help me if possible with this problem that I can not find a solution for, if it is not an inconvenience, and thanks in advance for your help, advice, or guidance.
The issue is that I am making a Point of Sale (POS), and I am developing the module of purchases of the system, this module is raised in ajax because the process is as follows:
How to do so that when making the purchase, the products that I bought are registered in the database with the same transaction number but in different rows? Ex:
For 3 products of the HTML table, loaded with the INFO of the form.
ID | NROTRANS | PRODUCTO
1 1 1
2 1 2
3 1 3
SIMPLE SOLUTION
Well I finally found the solution, what I did was to change the logic of product loading a bit, before you had to load all the products to the table through jquery, and at the end of the purchase is to insert the multiple rows to the database.
What I did was that now every time I fill out the form, I submit, I rescue by getting the $ _SESSION from the supplier I'm buying from and with header location redirected with that parameter to the same page, and I evaluate if the parameter is present in the URL, if so, I charge all the products associated with that supplier from the table acsi_posprecompra, and ready them on a table.
At the end of the purchase, the records associated with that provider are searched in the table acsi_posprecompra, the records are traversed by a while loop and inserted sequentially in the acsi_postransacciones table, after having finished the process, a DELETE is made to all records associated with that provider in the acsi_posprecompra table.
Sorry for not placing all the code, you will understand that it is extensive ...
Thanks to Hammerfall for responding, I tried it as you proposed but in the end it was not what they wanted ... But it was still a valid answer, work with arrays.