I am a PHP beginner and working on a simple project for learning purpose and at this point am trying to execute a while loop inside another while loop. But the second loop is inside a single quote string. The outputs of both loops are stored in a normal html/bootstrap table cells. At first I was able to get the output of the first loop but the problem came in when I added the second loop inside the string. I have already researched about using quotations in PHP but I still can't figure out the problem. Below is the code. Someone help please.
$output .='<div class="table-responsive">
<table class="table table-bordered"><form>';
while($row = $result->fetch_assoc()){
$output .='
<tr>
<td width="30%"><label>Price</label></td>
<td>
<div class="form-group">
<input type="text" class="form-control" placeholder="'.$row['price'].'">
</div>
</td>
</tr>
<tr>
<td width="30%"><label>Writer</label></td>
<td>
<div class="form-group">
<select class="form-control" id="">
'.while($col = $res->fetch_assoc()){.'
<option value="" disabled selected>'.$row['name'].'</option>
<option value="" >'. $col['username'].'</option>
'.} .'
</select>
</div>
</td>
</tr>
';
}
$output .="</table></div></form>";
echo $output;
}
The error am getting is: Parse error: syntax error, unexpected 'while' (T_WHILE) in C:\xampp\htdocs\Writers_SM\select.php on line 61(the second while loop )