3xtr3m3d
asked on
need idea
Hi
Im making a invoice system and my client needs invoice numbers in a order like 1,2,3,4 etc...
what i did was add a button to get new invoice then using ajax return last invoice number and add +1 to that number and save
problem is if two people use system at same time there is a possibility that both will get same number :(
what is the best way to solve this ?
Sorry for my bad english, hope someone will understand what i meant
Thanks
Im making a invoice system and my client needs invoice numbers in a order like 1,2,3,4 etc...
what i did was add a button to get new invoice then using ajax return last invoice number and add +1 to that number and save
problem is if two people use system at same time there is a possibility that both will get same number :(
what is the best way to solve this ?
Sorry for my bad english, hope someone will understand what i meant
Thanks
Generate the invoice number when the record is saved rather than when you open a new page to create one.
ASKER
is there a easy way to insert and return the id of that inserted record [id=autoincrement]?
currently im doing in this way
SELECT ID FROM tblinvoice ORDER BY ID DESC LIMIT 1
currently im doing in this way
SELECT ID FROM tblinvoice ORDER BY ID DESC LIMIT 1
SELECT MAX(ID) FROM tblinvoice is a good method
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You may use a primary key in a table on the server side.
http://dev.mysql.com/doc/refman/5.0/en/constraint-primary-key.html
http://dev.mysql.com/doc/refman/5.1/en/create-table-select.html
http://dev.mysql.com/doc/refman/5.0/en/constraint-primary-key.html
http://dev.mysql.com/doc/refman/5.1/en/create-table-select.html
sorry guys, I did not refreshed the page
ASKER
galexander07 , OP_Zaharin thanks for the information seems like best way is use mysql_insert_id()
Thanks all for the support.
Thanks all for the support.
NP, glad to help!
no prob 3xtr3med :)