<? $con = mysql_connect("localhost","root","1234"); $db = mysql_select_db("onlineshop",$con)or die ('ติดต่อฐานข้อมูลไม่ได้ '); mysql_query("SET NAMES tis620"); $sql = "SELECT * FROM product " ; $result = mysql_query($sql); $num = mysql_num_rows($result); $perPage = 4; $page = $_GET["page"]; if(!$_GET["page"]){ $page=1; } $prevPage = $page-1; $nextPage = $Page +1; $PageStart = (($perPage*$page)-$perPage); if($numRow <= $perPage ){ $numPage=1; }else if(($numRow%$perPage)==0){ $numPage =($numRow/$perPage); }else{ $numPage =($numRow/$perPage)+1; $numPage = (int)$numPage; } $sql .= "ORDER BY pid ASC LIMIT $PageStart"; $result = mysql_query($sql); echo "<table border =\"0\" cellspacing =\"1\" cellpadding =\"1\"><tr>"; $intRow = 0; while ($row = mysql_fetch_array($result)){ $productID = $row['pid']; $productName = $row['pname']; $productDes = $row['description']; $productPrice = $row['price']; $productType = $row['type']; $productNum = $row['num']; $productImage = $row['image']; echo "<td>"; $intRow++; ?> <center><img src="pic/<?=$productImage ?>" width="180" height="170" > <? echo" รหัสสินค้า : ". $productID."<br> ชื่อสินค้า : " .$productName."<br> ราคา : ".$productPrice."<br><a href='minishow.php?$pid=$prodectID'> รายละเอียดสินค้า</a> <a href='minishow.php?$pid=$prodectID'> หยิบลงตะกร้า</a>" ?> </center> <? echo "</td>"; if(($intRow)%2==0){ echo"</tr>"; } echo "</tr></table>"; ?> <br /> Total <?= $numRow; ?> Record : <?= $numPage; ?> Page : <? if($prevPage){ echo "[ <a href ='$_SERVER[SCRIPT_NAME]?Page = $nextPage'>Next>>]</a>"; } } mysql_close(); ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง