Priya
Priya

Reputation: 13

Using php mysql set auto_increment primary value into other field

how can i set id primarykey auto_increment same value that automatically generating into my id field will also generate in other field in same table.

How could it possible?

Upvotes: 1

Views: 106

Answers (1)

Unni Babu
Unni Babu

Reputation: 1814

Use mysql_insert_id which returns last auto increment ID...

1) insert into first table, use mysql_insert_id() to get auto increment ID 2) after getting auto increment ID from 1st table, insert on second table with the ID you got.

for more refer http://php.net/manual/en/mysqli.insert-id.php

Upvotes: 1

Related Questions