<?php $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");//เชื่อมต่อฐานข้อมูลโดย ผ่านรหัสผ่าน ชื่อ username เพื่อผ่านเข้าไปเชื่อมต่อ $objDB = mysql_select_db("db_phon");//ติดต่อ ฐานข้อมูลชื่อ db_phon mysql_query("set NAMES utf8");// set ค่าชนิดภาษาให้เป็น utf8 บนหน้าเว้บที่แสดง $strSQL = "SELECT * FROM tb_buy_order "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 20; // จำนวน ที่แสดงต่อ page20หน้า $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1;//เก็บผล ตัวแปล - 1 ไว้ที่ ตัวแปล $Parev_Page $Next_Page = $Page+1;// เก็บผล ตัวแปล $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by id_order ASC LIMIT $Page_Start , $Per_Page";//เรียก page ตาม id_order $objQuery = mysql_query($strSQL); ?> <? while($objResult = mysql_fetch_array($objQuery)) { //ประกาศตัวแปร ที่ดึกมาจากตัวแปรมาเก็บไว้ที่ตัวแปร ทางผั่งขวามือ $id_order_out=$objResult['id_order']; $ProductName=$objResult['ProductName']; $count_order=$objResult['count_order']; $Related=$objResult['Related']; $date=$objResult['date']; $mont=$objResult['mont']; $year=$objResult['year']; ?> <center> <table class="class_table" bordercolor="#00CCFF"><tr><td><th width="100"><div id="tabs10"><font color="#00FF00" size="-2"><? echo"$id_order_out";?></font></div></th></td><td><th width="100"><div id="tabsJ"><font color="#99FF00" size="-2"><? echo"$ProductName";?></font></div></th></td><td><th width="100"><font color="#FFFFFF" size="-2"><? echo"$count_order";?></font></th></td> <td><th width="100"><font color="#FFFFFF" size="-2"> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page:</font> <? if($Prev_Page) { echo " <font color='#333333' size='2'><a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a></font> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "<font color='#333333' size='2'>[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]</font>"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo " <center><font color='blue'><a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a></font></center> "; } mysql_close($objConnect); ?>
$Per_Page = 2; // Per Page
Quote:if(!$_GET["Page"]) {
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง