I have 3 tables that are connected. The insurance table is connected with the customer table and rental details which are also connected with the customer table. I want to insert data into these tables at the same time. What should I put in ID's columns (not the main ID but correlated)? All main ID's are set on auto-increment. I tried with @@IDENTITY and mysql_insert_id. Here is my code
//inserting into insurance table
if($connection->query("INSERT INTO insurance (Collision_Coverage,
Medical_Coverage) VALUES ('$collision_coverage','$medical_coverage')"))
{
//inserting into customer table
if($connection->query("INSERT INTO customer (People_ID, Driving_License_No, Insurance_id) VALUES ('$current_user_id', '$driv_lic_num', @@IDENTITY)"))
{
//inserting into rental_details table
if($connection->query("INSERT INTO rental_details (Vehicle_ID,Customer_ID, Hire_Date, Hire_Days, Total_cost, Return_date) VALUES ('$current_vehicle_id', @@IDENTITY, '$pick_up_date', '$days_hired', '$total_cost', '$returning_date')"))