I have an option to send multiple rows into an table, i'm using an foreach to do that:
if (is_array($add['jobname'])) { $insert = "INSERT INTO job_offers (job_category, status) VALUES "; foreach ($add['job_name'] as $key => $value) { $insertedval[] = " ('" . safe($add['job_category'][$key]) . "', '" . safe($add['status'][$key]) . "')"; } } $insert .= implode($insertedval, ","); $last_id = db_query($insert, '+id?'); //gets the last generated ID, its a function that i created, and working great. The problem is that i want to get the last ID, and i'm getting, but i'm inserting multiple rows into the database, and i want to get the ID's from all the inserted values, because they are being sent at the same time.
I can't put the $last_id variable inside the foreach loop, what do i do?
ps: i'm using auto increment
safe()?