$result = mysql_query("SELECT * FROM Table"); while ($ob = mysql_fetch_array($result)) { $arResult[$ob["year"]][$ob["tream"]][] = $ob } echo "<pre>"; print_r( $arResult); echo "</pre>";
<?php $objQuery = mysql_query("SELECT * FROM `ตาราง` ORDER BY `year` ASC,`trem` ASC,`sub_id` ASC") OR die("mysql_error: ".mysql_error()); $year = $term = $i = 0; ?> <table> <?php while ($objResult = mysql_fetch_assoc($objQuery)) : ?> <?php if( ($objResult['year'] != $year) OR ($objResult['year'] == $year && $objResult['trem'] != $trem) ) : $year = $objResult['year']; $term = $objResult['trem']; $i = 1; ?> <tr> <td colspan="3" style="text-align: center;"> เทอมที่ <?php echo $year; ?> ปีการศึกษา <?php echo $term; ?> </td> </tr><?php endif; ?> <tr> <td><?php echo $i++; ?></td> <td><?php echo $objResult['sub_id']; ?></td> <td></td> </tr> <?php endwhile; ?> </table>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง