jeeva Posted June 8, 2007 Share Posted June 8, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/54711-auto-increament-with-text/ Share on other sites More sharing options...
jaikar Posted June 8, 2007 Share Posted June 8, 2007 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.. Quote Link to comment https://forums.phpfreaks.com/topic/54711-auto-increament-with-text/#findComment-270559 Share on other sites More sharing options...
jeeva Posted June 8, 2007 Author Share Posted June 8, 2007 i guess it will help me...thank u very much.... Quote Link to comment https://forums.phpfreaks.com/topic/54711-auto-increament-with-text/#findComment-270575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.