Click here to Skip to main content
15,902,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all ! i am a young php developer.I want to create a auto increment function for ID Field in php .How could i create it ? show me some? thank you first!<pre></pre>
Posted

PHP is not responsible for the auto increment. This is done by the database engine. I assume you use MySQL. In that case you should apply the AUTO_INCREMENT attribute to the ID field.

Have a look at this link for more info:

http://dev.mysql.com/doc/refman/5.1/en/example-auto-increment.html[^]

Good luck!
 
Share this answer
 
v2
I try to use auto_increment attr but when i delete a record number still increase over one.so if you have other solution help me. thank
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900