I want to update the value of a column from a mysql table with the result from a mysql_fetch_array
But the last result is just the one being inserted/updated into the column
Where am i having wrong? Here's my code. Thanks in advance
$studentname="some value";
$course="some value";
$query=mysql_query("select SABJEK,GRADE,REMARKS from table where STUDENTNAME='$studentname' && STUDENTNUMBER IS NULL") or die(mysql_error());
while($result=mysql_fetch_array($query))
{
$sabjek=$result['SABJEK'];
$grade=$result['GRADE'];
$remarks=$result['REMARKS'];
$msg="$sabjek = $grade - $remarks ";
$msg1="$studentname $course $msg";
}
mysql_query("update table2 set `msg`='$msg1' where studentname='$studentname'") or die(mysql_error());