You have few issues in your code:
Issue 1: you can't concat function as like a variable, you just need to break your code and store in a variable then use Concat, otherwise, this will give you parse error.
Issue 2: Dont know why are you using $code=0 as $row in your foreach, this will give you Invalid argument error.
Issue 3: This is just my assumption, according to this id="trainingCode_' . $key + 1 . '" you are using this code inside a loop, if yes then this part name="trainingCode[]" also will create an issue when you fetch record, how would you know the correct relation?
Your Code Example:
<?php
$myString = '<tr>
<td style="width:30%" id="trainingCode_' . $key + 1 . '">
<select class="select2 form-control" data-live-search= "true" name="trainingCode[]">
<option value="0">SELECT CODE</option>';
// use your foreach loop here
foreach ($code as $row) {
$myString .= '<option value="'.$row.'">'.$row.'</option>'; // contact wit $myString
}
$myString .= '</select></td></tr>';
$traning[] = $myString;
?>