By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,638 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,638 IT Pros & Developers. It's quick & easy.

how to auto increment in php code?

P: 18
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `claims` (
  2. `id` BIGINT NOT NULL AUTO_INCREMENT ,
  3. `datecreated` DATE NOT NULL ,
  4. `timecreated` TIME NOT NULL ,
  5. `ref_no` VARCHAR( 50 ) NOT NULL ,
  6. `emp_id` BIGINT NOT NULL ,
  7. `emp_no` VARCHAR( 10 ) NOT NULL ,
  8. `emp_name` VARCHAR( 255 ) NOT NULL ,
  9. `pp_name` VARCHAR( 100 ) NOT NULL ,
  10. `claim_amt` DOUBLE NOT NULL ,
  11. `link_month` VARCHAR( 2 ) NOT NULL ,
  12. `link_year` VARCHAR( 4 ) NOT NULL ,
  13. PRIMARY KEY ( `id` )
  14. );
may i know how make id in auto increment in php code?
Apr 21 '08 #1
Share this Question
Share on Google+
3 Replies


mwasif
Expert 100+
P: 801
CREATE TABLE `claims` (
`id` BIGINT NOT NULL AUTO_INCREMENT ,
`datecreated` DATE NOT NULL ,
`timecreated` TIME NOT NULL ,
`ref_no` VARCHAR( 50 ) NOT NULL ,
`emp_id` BIGINT NOT NULL ,
`emp_no` VARCHAR( 10 ) NOT NULL ,
`emp_name` VARCHAR( 255 ) NOT NULL ,
`pp_name` VARCHAR( 100 ) NOT NULL ,
`claim_amt` DOUBLE NOT NULL ,
`link_month` VARCHAR( 2 ) NOT NULL ,
`link_year` VARCHAR( 4 ) NOT NULL ,
PRIMARY KEY ( `id` )
);

may i know how make id in auto increment in php code?
You don't need to make auto increment the id in PHP. Only insert the data without mentioning id column in the query .e.g

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO claims (datecreated) values ('2008-04-21');
Apr 21 '08 #2

ronverdonk
Expert 2.5K+
P: 4,258
Or, when you use all values in your insert, specify a zero (0) for the auto_increment column.

Ronald
Apr 21 '08 #3

P: 18
i get it aldy. thank you
Apr 22 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.