You would have to move lines 122-126 down inside the loop after line 371 so that it would be re-created for each row.
Then you can display the specialty value in another loop.
Perhaps an easier solution, since you wouldn't need a second loop, is to use this select statement for the second query:
$query_rsSpec1 = "SELECT GROUP_CONCAT(specialty) AS specialties FROM specialtytbl WHERE specialtyID IN (".$WADAmaintbl['specialtiesID'].")";
And then you can display it as: <?php echo($row_rsSpec1['specialties']); ?>