Hi,

I am trying to insert into 2 tables at once.

The first table i have a hidden field InsuranceID and that gets an auto increment from mysql database.

In my other hidden fields i am inserting into table 2 which has a hidden value of ProductID

This is set to get the value from InsuranceID however it comes back with column cannot be null as i am assuming the InsuranceID is not getting its value until after the insert.

So how can i AI the InsuranceID before it inserts so that ProductID gets a valid value and inserts into its table?

Hope someone can help on this.

cheers

Check php's mysql_insert_id or mysql's last_insert_id

Both functions return the auto increment id from the previous insert query.

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.