While looping, you just step through both arrays and then in the insert, you would insert both the values.
There wouldn't be any issue, since it is one insert statement that is inserting all the information, so the values will be inserted simultaneously. The reason you were having the issue is that it was 2 different statements to first insert and then update the row.