Jump to content

Recommended Posts

hi frnds,

 

i want generate a random number with text. For example i have to give one Reference number for a requisition whenever user submit the requisition.For that i need to create one random number like  GMS0001,GMS0002,GMS0003......etc,. and it will be stored in database.

Based on this reference id i have to show the data for user so it must be unique and auto increament. 

 

I know i will get this by using rand() function, but it has to come with text and order. 

 

 

any one can help me?

Link to comment
https://forums.phpfreaks.com/topic/54711-auto-increament-with-text/
Share on other sites

 

easiest way is to have 2 columbs for the record ID and the reference number seperatly. the recordID will get auto incremented, so while inserting a record, get the last record

 

$last_record = mysql_result(mysql_query('SELECT recordID FROM table ORDER BY recordID DESC LIMIT 1'), 0);

$referencenumber = 'GMS'.($last_record++);

 

inlcude the ref number while inserting the record.

 

you can also do this with having one column alone, then you have to do code it php according to your requirement..

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.