The way its written yes, it should.
However mysql for insertions also allows you to make use of one query for multiple records:
PHP Code:
$sql_d_id_swap = mysql_query("INSERT INTO confirmed (mem_id, d_id, contacts) VALUES('$mem_id', '$d_id', '$id'), ('$mem_id2', '$d_id2', '$id2')") or die (mysql_error());
If the op wanted, they could turn the 'values' into a string which gets concat'd inside the loop and then put into the query.