$query = mysql_query("select `subject` from `markssub1` where `sname`='$user' AND `sid`='$id'");
$subjects = [];
while($row = mysql_fetch_array($query))
{
$subjects[] = $row['subject'];
}
foreach($subjects as $subject){
echo $subject . '\n';
}