我有这张来自mysql的表,我使用以下代码输出,
<?php
$sql="SELECT * FROM $tbl_name WHERE subunit='$subunit' and part='$part' and session='$session' and class ='$class' order by names asc";
$result=mysql_query($sql);
while($data = mysql_fetch_row($result)){
echo strtoupper("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td><td>$data[5]</td><td>$data[6]</td><td>$data[7]</td></tr>");
}
?>
NAMES ID COURSES LETTER WEIGHT UNIT SUBUNIT SESSION PART CLASS
john 2012/185301 GSP111 F 0 ARTIST UNN 2012/2013 FIRST 100
john 2012/185301 HIS121 D 4 ARTIST UNN 2012/2013 FIRST 100
john 2012/185301 PHL101 D 4 ARTIST UNN 2012/2013 FIRST 100
jude 2011/176363 TRM201 C 6 ARTIST UNE 2012/2013 FIRST 200
jude 2011/176363 ACH211 D 4 ARTIST UNE 2012/2013 FIRST 200
mary 2011/176363 ACH231 B 12 ARTIST UNE 2012/2013 FIRST 200
请问我如何使它在每个不同的行结束后立即输出下表?
NAMES ID COURSES LETTER WEIGHT UNIT SUBUNIT SESSION PART CLASS
john 2012/185301 GSP111 F 0 ARTIST UNN 2012/2013 FIRST 100
john 2012/185301 HIS121 D 4 ARTIST UNN 2012/2013 FIRST 100
john 2012/185301 PHL101 D 4 ARTIST UNN 2012/2013 FIRST 100
total weight = 8
jude 2011/176363 TRM201 C 6 ARTIST UNE 2012/2013 FIRST 200
jude 2011/176363 ACH211 D 4 ARTIST UNE 2012/2013 FIRST 200
total weight = 10 ARTIST UNE 2012/2013 FIRST 200
mary 2011/176363 ACH231 B 12
total weight = 12