Will there be the same number in both arrays, or will the numbers differ?
Also, for efficiency and security, you should use prepared statements.
Prepare your query, with placeholders, just once, outside of the loop.
Then in the loop execute the query, changing the bound parameters in each iteration of the loop.
Never put user input data directly into a query like that, it is prone to SQL injection. Prepared statments will reduce that risk.
Also, when running the same query over and over in a loop with different values, preparing once, then only executing multiple times, with different values, is far more efficient.