i've always made my own php code, but now i got into a little problem, one of my customers wants to generate inceremental id's for it's customers that wii look like the folowing:
3-1-1 3-1-2 3-1-3 3-2-1 3-2-2 3-2-3 3-3-1 3-3-2 3-3-3 and so on...
each group of numbers (eg.1-1-1) representing a different id. for a customer. i've been playing along woth for, if, and while... but i just cann't seem to make this work... can anyone please give me some hints...
I want to make a php script to generate such codes....
I don't think that the database should be burdened like that. Create a function that generates the id, it just takes some logic and math (look at last id, increase necessary column).
I don't quite follow the logic of this identification method. Is there a limit of 999 customers (0-0-1 to 9-9-9) or can an id be like 10-23-124124? It just doesn't make much sense to me to have it increment like that. I'm assuming they have an existing system that identifies in this manner and they want to be consistent. I would suggest to them that they change their old system if possible.
I'll be fair and leave open the possibility that there is more to this id system than has been revealed here.
I see it as how you store it doesn't have to be completely identical to how you show it.
If you are using a database, why don't you just have 3 auto-incrementing fields for each entry. Pull each out and display as ' . $row[0] . '-' . $row[1] . '-' . $row[2] . ' If you need to, add another column to identify this combination and use this column's value for associations between other tables. If you are sure the integrity of the data from the three integers is secure, it doesn't matter if you do not store them in the 1-1-1 way, just display them that way.
It seems like it's a modified trinary counter (rather than binary) rather than starting at 0, it starts at 1. Binary is 01 , Trinary would be 012. So, you could write a translation function to base 3 that would work and still keep your stuff as it is.