srinivas6203 Posted August 1, 2008 Share Posted August 1, 2008 I am doing one website using php and mysql. Afeter complete the registration the user details stored into the database. At this time i want to prefix some number to auto increment id. For example user id is 3. I want to prefix some 999 to that id. Finally i want to store the id as "9993". Is this possible. If that is not possible. there is another way. make the number using some loop with starting 9991 to etc. Make sure those numbers are unique and must starts with 999. Per each registration i have put the number into database as user id. Can any one help me. Quote Link to comment Share on other sites More sharing options...
ShaunO Posted August 1, 2008 Share Posted August 1, 2008 So you want to go 9991 9992 9993 9994 9995 9996 9997 9998 9999 99910 99911 Like that? Quote Link to comment Share on other sites More sharing options...
srinivas6203 Posted August 1, 2008 Author Share Posted August 1, 2008 yes ShaunO exactly Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted August 1, 2008 Share Posted August 1, 2008 create an auto_increment field, to keep track of the auto increments. create another field to hold the user id. Basic: mysql_query("INSERT INTO tableName (`name`,`email`) VALUES ('$name','$email')"); mysql_query("UPDATE tableName set userID = '999".mysql_insert_id()."' WHERE id = '".mysql_insert_id()."'"); Quote Link to comment Share on other sites More sharing options...
srinivas6203 Posted August 1, 2008 Author Share Posted August 1, 2008 Hi The Little Guy Thanq for ur cooperation. I tried that script wha u have to send. the auto increment id was added (+) to prefix by using your script. Example: Auto increment id is 1. Our prefix is 999. After update the table the id value is 1000 (999+1). But i want 9991. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted August 1, 2008 Share Posted August 1, 2008 Hi The Little Guy Thanq for ur cooperation. I tried that script wha u have to send. the auto increment id was added (+) to prefix by using your script. Example: Auto increment id is 1. Our prefix is 999. After update the table the id value is 1000 (999+1). But i want 9991. ??? I'm sorry, I didn't quite understand that... Quote Link to comment Share on other sites More sharing options...
srinivas6203 Posted August 1, 2008 Author Share Posted August 1, 2008 Nothing there The Little Guy The auto increment id was adding to prefix. Not concatenate. if id is "1" and prefix is 999. After using your script the id is 999+1 means i get the id is "1000". but i want 9991 Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted August 1, 2008 Share Posted August 1, 2008 It shouldn't add, you must be doing it wrong, because when I run it on my server I get: 9991 9992 9993 etc. Quote Link to comment 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.