Automatically generate a number for a collection of items


I plan to create an identity number automatically whenever a COLLECTION of items is submitted into the database, that is, whenever a transaction is successfully executed in my application.

Looking at receipt vouchers, it might contain many different items but all the items in that particular receipt would have the same receipt and the receipt would have only ONE NUMBER.

It's like you're capturing records into a table. Immediately you click on the submit (insert into) button, a unique ID should be automatically generated.

How do I go about this plz?

The context of your question is a little unclear, but... if you want to generate a unique identify number whilst filling in a form - to tag a collection of items, or any other purpose for that matter - then perhaps take a look at uuid() to see if that will fulfill your need.

Thank you for your feedback.
Yes, what you just said is what I want. I clicked the link you shared but it doesn't tell one how to apply the method. No algorithm as an example for one to learn from.

Can you guide me on how to achieve my aim please?

I want when a user lists the items in a receipt form, immediately he submits the form, a unique number will be automatically generated for the form, which can be called the form number or receipt number.