i'm making a car info form in the admin panel. I want to add 6 images which would have the same id as the car info
form
car info selectors (x12)
file input (x6)
/form
2 separate tables (cars and images)
how do i give all the file inputs the same id as the car info? i'm new to programming, but in my mind i have to use max(id) from the car table, add +1 and give it to all the input files carID when inserting them to the database. Is there and easier way to do this? or is my logic faulty?
If you are using mysqli in php then use the mysqli_insert_id function
http://www.php.net//manual/en/mysqli.insert-id.php
This gives you the id of the last record inserted.
You should never just use the max id. Entirely possible another record has been inserted by another user / process between your insert and you following inserts of dependent records.