$sql="select * from type order by t_id desc";
<table width="635" height="309" border="0" align="center" cellpadding="4" cellspacing="4"> <tr> <td align="left" valign="top" scope="col"><table width="44%" height="115" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr> <td height="30" align="center" valign="middle" bgcolor="#6699FF"><span style="font-size: 14px; font-weight: bold">เพิ่มประเภท </span></td> </tr> <tr> <td width="53%" height="83" valign="top"><div align="center"> <table width="100%" height="70" border="0" cellpadding="0" cellspacing="0"><form name="frm1" method="post" action="admin_type_save.php" onSubmit="return checkfield();"> <tr> <td width="24%" height="41"><div align="right">ชื่อประเภท</div></td> <td width="4%"> </td> <td width="57%"><div align="left"> <input name="type" type="text" id="type" size="20"> </div></td> <td width="15%"> </td> </tr> <tr> <td> </td> <td> </td> <td height="29"><div align="center"> <input type="submit" name="Submit" value=" เพิ่ม "> </div></td> <td> </td> </tr> </form> </table> </div></td> </tr> </table> <p> </p> <table width="50%" height="105" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" valign="top" scope="col"><table width="100%" height="85" border="0" align="center" cellpadding="0" cellspacing="1"> <tr bgcolor="#FFFFFF"> <th scope="col"> </th> <th scope="col"> </th> <th scope="col"> </th> <th height="21" scope="col"> </th> </tr> <tr align="center" bgcolor="#e33535"> <td width="16%" bgcolor="#6699FF" scope="col"><span class="style4" style="font-weight: bold">ลำดับที่</span></td> <td width="33%" bgcolor="#6699FF" scope="col"><span class="style4"><strong>ชื่อประเภท</strong></span></td> <td width="14%" bgcolor="#6699FF" scope="col"> </td> <td width="14%" height="21" bgcolor="#6699FF" scope="col"> </td> </tr> <? include("connect.php"); $sql="select * from type order by t_id desc"; //$result=mysql_query($sql); $i=1; $q1=mysql_query("select count(t_id) from type "); $numrow=mysql_result($q1, 0, 0); // เปิดตัวแปรกำหนดจำนวน record ที่ต้องการแสดงในแต่ละหน้า $perpage=10; /*เอาจำนวน record ทั้งหมดมาหารจำนวน record ต่อหน้า ดูว่าต้องแสดงทั้งหมดกี่หน้า โดยหาเป็นจำนวนเต็ม*/ if($numrow>0 ) $numpage=intval($numrow/$perpage); // ถ้าหารแล้วมีเศษก็บวกมันเข้าไปอีกหน้านึง if($numrow%$perpage>0) $numpage=$numpage+1; echo "หน้า :: "; /* ทีนี้ก็ loop แต่ละหน้า โดยเปลี่ยนตรง start คือเริ่มจาก record ที่เท่าไหร่ แต่ละหน้าก็จะขยับไปเรื่อยๆ >> หน้าสองเริ่มที่ 5 */ for ($i=0; $i<$numpage; $i++) { $st=$i * $perpage; $ii=$i+1; if($p=="")$p=1; if($p==$ii){ print "[<a href='$PHP_SELF?start=$st&p=$ii'>$ii</a>]"; }else{ print " <a href='$PHP_SELF?start=$st&p=$ii'>$ii</a> "; } } print "::"; if(!$start) $start=0; // ตรงนี้เป็นคำสั่ง sql ให้ select มา โดยใช้ limit จุดเริ่ม , จำนวนrecord $query='select * from type order by t_id desc limit '.$start.', '.$perpage.''; $result=mysql_query($query) or die("Error"); $numrow=mysql_num_rows($result); //if($numrow==0) print "<tr><td height=\"18\" colspan=6 align=center><font size=\"+1\" color=\"#FF0000\">ยังไม่มีกระทู้ค่ะ</font></td></tr>"; //$sql="select * from product "; // $result=mysql_query($sql); $row=mysql_num_rows($result); while($rec=mysql_fetch_array($result)){ $name=$rec[t_name]; ?> <tr bgcolor="#E5E5E5"> <td height="18" bgcolor="#E5E5E5" scope="col"><? echo $i?></td> <td bgcolor="#E5E5E5" scope="col"><? echo $name?></td> <td bgcolor="#E5E5E5" scope="col"><a href="admin_type_edit.php?t_id=<?=$rec[t_id]?>" class="style4">แก้ไข</a></td> <td height="21" bgcolor="#E5E5E5" scope="col"><a href=" admin_type_delete.php?t_id=<?=$rec[t_id]?>" class="style5" onClick="return confirm(' คุณต้องการลบประเภท <?=$rec[t_name]?> ใช่หรือไม่')">ลบ</a></td> </tr> <? $i=$i+1; } ?> <tr> <th bgcolor="#FFFFFF" scope="col"> </th> <th bgcolor="#FFFFFF" scope="col"> </th> <th bgcolor="#FFFFFF" scope="col"> </th> <th height="22" bgcolor="#FFFFFF" scope="col"> </th> </tr> </table></td> </tr> </table></td> </tr> </table>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง