I have table B that has reference to table A. I need to insert value to table B's foreign key. How to do it using PHP? Do I need to use mysql_insert_id()?

Recommended Answers

All 2 Replies

you can directly make change in database or use this:-

mysql_query("Alter table table_name add constraint pk_key PRIMARY KEY (column_name)");
commented: helpful! +3

I used mysql_insert_id(). Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.