<?php require("config.inc.php"); if (empty($page)){ $page=1; } mysql_connect($host,$username,$password) or die("ติดต่อฐานข้อมูลไม่ได้"); mysql_select_db($db)or die ("เลืกข้อมูลไม่ได้"); $sql = "select * from downtime "; $result = mysql_query("select id from downtime order by ID DESC"); $dbquery = mysql_db_query($db,$sql); $NRow = mysql_num_rows($result); $num_rows = mysql_num_rows($dbquery); $rt = $NRow%$list_page; if($rt!=0) { $totalpage = floor($NRow/$list_page)+1; } else { $totalpage = floor($NRow/$list_page); } $goto = ($page-1)*$list_page; $sql = "select * from downtime where id order by id DESC limit $goto,$list_page"; $result = mysql_db_query($db,$sql); $NRow = mysql_num_rows($result); if($NRow==0) { echo "<center>"; echo "<font size=\"+1\" face='MS Sans Serif'>ยังไม่มีมีใบแจ้งซ่อม</font><br><br>\n"; } else { while($row = mysql_fetch_array($result)) { ?> <tr> <td width="5%" bgcolor="#CCCCFF" align="center"><?php echo sprintf("<B>%06d</B>",$row[0]) ; ?></td> <td width="5%" bgcolor="#CCCCFF" align="center"><?php echo $row[1] ; ?></td> <td width="8%" bgcolor="#CCCCFF" align="center"><?php echo $row[3] ; ?></td> <td width="5%" bgcolor="#CCCCFF" align="center"><?php echo $row[4] ; ?></td> <td width="13%" bgcolor="#CCCCFF" align="center"><?php echo $row[5] ; ?></td> <td width="8%" bgcolor="#CCCCFF" align="center"><?php echo $row[6] ; ?></td> <td width="13%" bgcolor="#CCCCFF" align="center"><?php echo $row[8] ; ?></td> <td width="5%" bgcolor="#CCCCFF" align="center"><?php echo $row[12] ; ?></td> </tr> <?Php } ?> </table> <br> <?php $result = mysql_query("select count(id) from downtime"); $row = mysql_fetch_row($result); $num = $row[0]; echo "<center>"; if ($num == "") { $entry = "ยังไม่มีผู้เซ็นต์สมุดเยี่ยมเลย2"; } else { $entry = "มีผู้เซ็นต์สมุดเยี่ยมแล้วจำนวน <Font color=red> $num </Font>คน"; } echo "<BR>$entry "; echo "</center>"; echo "<center>"; if($page>1 && $page<=$totalpage) { $prevpage = $page-1; echo "\t<a href='view.php?&page=$prevpage'>[หน้าก่อน = $prevpage]</a>\n"; } echo "\t กำลังแสดงหน้าที่ $page/$totalpage \n"; if($page!=$totalpage) { $nextpage = $page+1; echo " <a href='view.php?&page=$Next_Page'> Next >></a> "; //echo "\t<a href='view.php?&page=$nextpage'>[หน้าถัดไป = $nextpage]</a>\n"; } // echo "\t</font>\n"; //echo "</td></tr>\n"; //echo "<tr><td>\n"; // วนลูปแสดงเลขหน้าทั้งหมด for($i=1 ; $i<$page ; $i++) { echo "\t<a href='view.php?&page=$i'>$i</a> \n"; } echo "\t<font size=2 color=red><b>$page</b></font> \n"; for($i=$page+1 ; $i<=$totalpage ; $i++) { echo "\t<a href='view.php?&page=$i'>$i</a> \n"; } echo "</td></tr>\n"; echo "</table>\n"; echo "</center>"; } ?>
if (empty($_GET["page"])){ $page=1; } else { $page=$_GET["page"]; }
<html> <head> <title>ThaiCreate.Com PHP & MySQL Tutorial</title> </head> <body> <? $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase"); $strSQL = "SELECT * FROM customer "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $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 CustomerID ASC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?=$objResult["CustomerID"];?></div></td> <td><?=$objResult["Name"];?></td> <td><?=$objResult["Email"];?></td> <td><div align="center"><?=$objResult["CountryCode"];?></div></td> <td align="right"><?=$objResult["Budget"];?></td> <td align="right"><?=$objResult["Used"];?></td> </tr> <? } ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> "; } mysql_close($objConnect); ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง