$id mysql_insert_id($mysql); foreach($tags as ) { $query2 = "INSERT INTO tags (id, tag) VALUES ('$id','')"; }