โค้ดของผม
โค้ด: เลือกทั้งหมด
<?
$hostname="localhost";
$user="root";
$password="1234";
$dname="support";
mysql_connect($hostname,$user,$password)or die("can't connect DB");
mysql_select_db($dname)or die("can't connect DB");
mysql_query("SET NAMES UTF8");
$sql = "select * from grade where $search like '%$search_textbox%' and Teacher_Id='$_SESSION[ssUserID]' ORDER BY `grade`.`year` ASC";
$dbquery = mysql_db_query("support",$sql);
$num_rows = mysql_numrows($dbquery);
?>
<?
$rowNo = 0;
while ($result = mysql_fetch_array($dbquery)) {
$id_subject = $result[id_subject];
$subject = $result[subject];
$Teacher_Id = $result[Teacher_Id];
$Teacher_Name = $result[Teacher_Name];
$Student_Id = $result[Student_Id];
$Stu_Name = $result[Stu_Name];
$Section_Id = $result[Section_Id];
$CR = $result[CR];
$gp = $result[gp];
$term = $result[term];
$year = $result[year];
$t_y = $result[t_y];
?>
<table width="812" border="1" cellpadding="0" cellspacing="0">
<tr>
<td colspan="8" align="left" bgcolor="#99CCFF"><div align="center">ภาคการศึกษาที่ <?php echo $t_y; ?><? $rowNo++ ?> </div></td>
</tr>
<tr>
<td width="94" align="left" bgcolor="#99CCFF"><div align="center">รหัสวิชา</div></td>
<td width="556" align="left" bgcolor="#99CCFF"> <div align="center">ชื่อรายวิชา</div></td>
<td width="82" align="left" bgcolor="#99CCFF"><div align="center">หน่วยกิต</div></td>
<td width="70" align="left" bgcolor="#99CCFF"><div align="center">เกรด</div></td>
</tr>
<tr height="22" valign="middle" bgcolor="#FFCC99">
<td width="94" align="left" bgcolor="#FFCC99"><div align="center"><?php echo $id_subject ?></div></td>
<td width="556" align="left" bgcolor="#FFCC99"> <div align="center"><?php echo $subject ?></div></td>
<td width="82" align="left" bgcolor="#FFCC99"><div align="center"><?php echo $CR ?></div></td>
<td width="70" align="left" bgcolor="#FFCC99"><div align="center"><?php echo $gp ?></div></td>
</tr>
<?
}
mysql_close();
?>
</table>
ช่วยดูหน่อยครับให้วนลูปยังไงไห้เป็นแบบตัวอย่าง