It seems like the loop might be occurring correctly, but maybe we are just not setting this variable that holds the queries correctly. Try updating this line in the server behavior:
$the_updates .= "<br/>" . $WA_Sql;
Update it to be like this:
$the_updates = $the_updates . "<br/>" . $WA_Sql;
If after making this update and testing the page you have the same result add in this line of code just after setting this update variable like this:
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
Please post back with your result.