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
https://forums.phpfreaks.com/topic/117713-mysql-auto-increment-problem/
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()."'");

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.

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

Archived

This topic is now archived and is closed to further replies.

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