Hi,

I have a problem. I am storing projectid (varchar) as a field in this format :- DD-NNN where DD is the last two digits of the year and NNN is the next project number within that year (i.e. 09-500 is the 500th project in year 2009). The user has the ability to modify the automatically generated projectid.

Plus, there is 1 internal only project for year 2009 (09-000). This project should automatically be created at the start of a new year.

How can this be done? Please help me out !

Thanks

I think you are going about this the wrong way.

Just use a regular auto_increment primary key field and then store the year in the rows themselves under a 'year' column.

Or you can just store the time the project was created in the database, which you can easily derive the year from with some simple mysql or php functions. That way you also have the creation time as well as the year.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.