I presume you distinguish between records with a primary key which is possibly again a number, auto incremented by MySQL. That gives you the uniqueness of each record and can be displayed at the beginning of each line for your output i.e.:
#342 Ticket
#343 Ticket
#477 Ticket
etc.
Now if you categorize your tickets and want for each category to show just a simple increment 1,2,3,etc. instead of the primary key which might cause the numbering not to be cunsecutive, you will need to store a number in your table for each record. You can add a new field which will be numeric (integer) and in that you will store the highest number of the ticket per category. All you will have to do is when a ticket is submitted you will query the database to find the max number existing and then increment it by one and store that in the new record.
The additional field approach allows you also to move tickets accordingly because their display order will be based on the new field and not on the primary key. If you want to move a ticket up or down all you will need is a couple of queries and a refresh.
I hope this helps