Welcome Guest, Not a member yet? Register   Sign In
Set autoincrement value for each value in row -- php
#5

[eluser]obiron2[/eluser]
I think his database table has a compound primary key of Row1/Row2 (bad field labelling!)
Think of them as OrderNumber/LineNumber

When you add a record to the database for a particular order number the line number should be one higher that the highest line number on that order.

To do this you will have to poll the database

$query = "SELECT max(lineno) as 'LineNo' from myTable where orderref = $orderRef"

$qUpdate "INSERT INTO myTable (OrderRef,LineNo) VALUES ($orderRef,($query->row()->lineno+1))"

You run the risk of concurrency issues if more than one browser window could update the order at the same time so you would need to look at some sort of record locking or pre-creating the row and then updating it.



Messages In This Thread
Set autoincrement value for each value in row -- php - by El Forum - 04-29-2013, 02:48 PM
Set autoincrement value for each value in row -- php - by El Forum - 04-29-2013, 09:19 PM
Set autoincrement value for each value in row -- php - by El Forum - 04-30-2013, 08:12 AM
Set autoincrement value for each value in row -- php - by El Forum - 05-01-2013, 05:03 AM
Set autoincrement value for each value in row -- php - by El Forum - 05-08-2013, 06:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB