Jump to content

mysql auto increment problem


srinivas6203

Recommended Posts

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.

Link to comment
Share on other sites

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()."'");

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.