//Last term
$selLast = "select TermFull from tbreportscheduleclass order by Years desc,Term desc;";
$qryLast = mysql_query($selLast)or die(mysql_error());
$rstLast = mysql_fetch_assoc($qryLast);
//Count numbers of students
$count = "select ClassID,count(ID) as count_id from dbo_student where Status = '1' group by ClassID;";
$qry_count = mysql_query($count)or die(mysql_error());
while($rst_count = mysql_fetch_assoc($qry_count))
{
mysql_query("update tbreportscheduleclass set Num_of_Stu = '".$rst_count["count_id"]."',Inc_of_Stu = '".$rst_count["count_id"]."',Limit_of_Stu = '".$rst_count["count_id"]."' where ClassID = '".$rst_count["ClassID"]."' and TermFull = '".$rstLast["TermFull"]."';")or die(mysql_error());
}