PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a table which stores client information. In this table I also need to store a field called case_number.
My client would like the case_number to be automatically generated when she adds a new client. And, she would like the case numbers to be sequential.
So if I have ClientA in a table with case number 2020 and I add ClientB to the table, I would like their case number to be 2021. And, if I add ClientC to the table, their case number sould be 2022. Etc.
Is it possible to write a script to generate a number in sequential order and store that number into a table?
If so, how do I go about scripting something like this?
Two ways to do this: query the server for the last entered number, increment, and insert the new row; or check out the auto_increment option when making tables.
Yes, use an Auto Increment field. The database engine will insure that every case number is unique. The numbers will be assigned consecutively, based on the exact sequence the records were inserted.