|
 |
|
กด Next แล้วมันไม่ไปอะครับ ตอนกดบน host นะ ในเครื่องไป |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
ob_start();
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
session_start();
require("connect/connect.php");
require("connect/function.php");
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>::: www.beautifulshop-dress.com :::</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" background="image/z06.jpg">
<table width="778" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php require_once('head.php'); ?>
</td>
</tr>
<tr>
<td><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#f2f2f6" bgcolor="#FFFFFF">
<tr>
<td width="15%" valign="top"> <?php require_once('menuleft.php'); ?> <br> </td>
<td width="69%" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100%" height="703" valign="top">
<table width="100%" height="448" border="0" align="center" background="image/z06.jpg">
<tr valign="top">
<td><strong> </strong>
<table width="100%" height="30" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
<td width="100%" background="image/menu02.jpg"><div align="center"><strong>
<?
//============ เลือกว่าเป็นหมวดอะไร
$resultHeadPro=select("category","where 1=1 and CatID='".$_GET["CatID"]."'");
if(!$resultHeadPro)
{
//header("location:index.php");
}
if($_GET["CatID"]!="")
{
echo "(".$resultHeadPro["CategoryName"].")";
}
else
{
echo "(แสดงทั้งหมด)";
}
?>
</strong> </div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><?
//============ เลือกรายการสินค้าออกมาแสดง
$condition="";
if($_GET["CatID"] <> "")
{
$condition="and CatID='$_GET[CatID]' ";
}
echo"<table align=center><tr>";
$sql = "select * from product where 1=1 $condition ";
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =60;
if(!$Page)
$Page=1;
//============ คำนวณจำนวนหน้า
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result=mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
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;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
$sql .= " order by ProductID DESC LIMIT $Page_start , $Per_Page";
//ส่วนแสดงผล
$i=0;
$query = mysql_query($sql);
While($resutNewPro= mysql_fetch_array($query)){
$i++;
echo "<td>";
?>
<table width="120" height="105" border="1" cellpadding="3" cellspacing="0" align="center" background="image/z06.jpg">
<tr>
<td height="60" valign="top" bgcolor="#FFCCFF"><div align="center"><a href="detail.php?CatID=<?=$resutNewPro["CatID"];?>&ProductID=<?=$resutNewPro["ProductID"];?>"><img src="picture/<?=$resutNewPro["Picture"];?>" width="150" height="170" border="0"></a></div></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFF33"><div align="center"> <a href="detail.php?CatID=<?=$resutNewPro["CatID"];?>&ProductID=<?=$resutNewPro["ProductID"];?>">
<?=$resutNewPro["ProductName"];?>
</a><br>
ปกติ
<?="(<s>".number_format($resutNewPro["PriceNormal"], 2,'.',',')."</s>";?>
บาท) <br>
<font color="#FF0000"><strong>พิเศษ</strong></font>
<?="(".number_format($resutNewPro["Price"], 2,'.',',');?>
บาท)<br>
ค่าจัดส่ง
<?="(".number_format($resutNewPro["PriceSend"], 2,'.',',');?>
บาท)</div></td>
</tr>
</table>
<?
//============ แสดงแถวละ 4
echo"</td>";
if(($i)%4==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
if($i==0)
{
echo "<strong><center><font color=red>ไม่มีรายการสินค้า</font></center></strong>";
}
?>
<hr width="98%" color="#f2f2f6">
<table width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" colspan="10" class="boxtext"><div align="center">จำนวน
<?=$Page;?>
หน้า <b>
<?=$Num_Pages;?>
</b> (
<?= $Num_Rows;?>
รายการ) </div></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="1" cellspacing="1" align="center">
<tr>
<td><div align="center">
<?/* สร้างปุ่มย้อนกลับ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page&CatID=$_GET[CatID]' class='boxtext'><< Back </a> ";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo " [ <a href='$PHP_SELF?Page=$i&CatID=$_GET[CatID]' class='boxtext'>$i</a> ]";
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo " <a href ='$PHP_SELF?Page=$Next_Page&CatID=$_GET[CatID]' class='boxtext'> Next >> </a>";
?>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td width="100%" height="16" align="center"> </td>
</tr>
</table>
</p></td>
</tr>
</table></td>
<td width="16%" valign="top"> <?php require_once('menuright.php'); ?> </td>
</tr>
<tr>
<td colspan="3" valign="top">
<?php require_once('down.php'); ?>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
Tag : PHP, CakePHP

|
|
 |
 |
 |
 |
Date :
2011-08-09 23:09:07 |
By :
tormam |
View :
894 |
Reply :
9 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือว่าตอนนี้มันกด Next ที่บน Host จริง มันไม่ไปหน้าต่อไปครับ มันเข้ามาหน้าเดิม แต่ตอนลองใน localhost มันได้นะครับ
|
 |
 |
 |
 |
Date :
2011-08-09 23:16:56 |
By :
tormam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้ผมลอง echo $sql; จากบรรทัด 99 มันบอกแบบนี้
select * from product where 1=1 ORDER BY ProductID DESC LIMIT 0 , 60
ตอนนี้ รูปมี 62 รูป คับ แต่กดไม่ไป
|
 |
 |
 |
 |
Date :
2011-08-09 23:41:25 |
By :
tormam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo ค่า $PHP_SELF ออกมาดูสิครับ ว่ามีค่าหรือเปล่า
|
 |
 |
 |
 |
Date :
2011-08-09 23:44:22 |
By :
nobuts |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
select * from product where 1=1 ORDER BY ProductID DESC LIMIT 0 , 60
ออกมาแบบนี้
|
 |
 |
 |
 |
Date :
2011-08-10 14:33:01 |
By :
tormam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
if(!$_GET['Page'])
$Page=1;
else
$Page=$_GET['Page'];
|
 |
 |
 |
 |
Date :
2011-08-10 14:44:28 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
PlaKriM พี่คับ อธิ บาย ที่ คือว่าต้องทำไง
|
 |
 |
 |
 |
Date :
2011-08-10 15:09:00 |
By :
tormam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ต้องเอาไว้หรือแก้ บรร ทัดไหน
|
 |
 |
 |
 |
Date :
2011-08-10 15:33:10 |
By :
tormam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ครับ กดไปแล้วครับ ว่าแต่ถ้าผมต้องการให้มัน เป็นหน้าออกมาแบบ <<<Back [1][2][3]....[50] Next >>> ไม่ทราบว่าต้องแก้หรือเพิ่ม อะไรไหมครับ ผม ลอง เอาจาก ลิงค์ นี้มา ยำแล้ว มันไม่ได้ https://www.thaicreate.com/community/php-mysql-pagination.html
โค้ด ตอนนี้
Code (PHP)
<?
ob_start();
//============ Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
session_start();
require("connect/connect.php");
require("connect/function.php");
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>::: www.beautifulshop-dress.com :::</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" background="image/z06.jpg">
<table width="778" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php require_once('head.php'); ?>
</td>
</tr>
<tr>
<td><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#f2f2f6" bgcolor="#FFFFFF">
<tr>
<td width="15%" valign="top"> <?php require_once('menuleft.php'); ?> <br> </td>
<td width="69%" valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100%" height="703" valign="top">
<table width="100%" height="448" border="0" align="center" background="image/z06.jpg">
<tr valign="top">
<td><strong> </strong>
<table width="100%" height="30" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<tr>
<td width="100%" background="image/menu02.jpg"><div align="center"><strong>
<?
//============ เลือกว่าเป็นหมวดอะไร
$resultHeadPro=select("category","where 1=1 and CatID='".$_GET["CatID"]."'");
if(!$resultHeadPro)
{
//header("location:index.php");
}
if($_GET["CatID"]!="")
{
echo "(".$resultHeadPro["CategoryName"].")";
}
else
{
echo "(แสดงทั้งหมด)";
}
?>
</strong> </div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><?
//============ เลือกรายการสินค้าออกมาแสดง
$condition="";
if($_GET["CatID"] <> "")
{
$condition="and CatID='$_GET[CatID]' ";
}
echo"<table align=center><tr>";
$sql = "select * from product where 1=1 $condition ";
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =60;
if(!$_GET['Page'])
$Page=1;
else
$Page=$_GET['Page'];
//============ คำนวณจำนวนหน้า
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result=mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
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;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
$sql .= " ORDER BY ProductID DESC LIMIT $Page_start , $Per_Page";
//ส่วนแสดงผล
$i=0;
$query = mysql_query($sql);
While($resutNewPro= mysql_fetch_array($query)){
$i++;
echo "<td>";
?>
<table width="120" height="105" border="1" cellpadding="3" cellspacing="0" align="center" background="image/z06.jpg">
<tr>
<td height="60" valign="top" bgcolor="#FFCCFF"><div align="center"><a href="detail.php?CatID=<?=$resutNewPro["CatID"];?>&ProductID=<?=$resutNewPro["ProductID"];?>"><img src="picture/<?=$resutNewPro["Picture"];?>" width="150" height="170" border="0"></a></div></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFF33"><div align="center"> <a href="detail.php?CatID=<?=$resutNewPro["CatID"];?>&ProductID=<?=$resutNewPro["ProductID"];?>">
<?=$resutNewPro["ProductName"];?>
</a><br>
ปกติ
<?="(<s>".number_format($resutNewPro["PriceNormal"], 2,'.',',')."</s>";?>
บาท) <br>
<font color="#FF0000"><strong>พิเศษ</strong></font>
<?="(".number_format($resutNewPro["Price"], 2,'.',',');?>
บาท)<br>
ค่าจัดส่ง
<?="(".number_format($resutNewPro["PriceSend"], 2,'.',',');?>
บาท)</div></td>
</tr>
</table>
<?
//============ แสดงแถวละ 4
echo"</td>";
if(($i)%4==0)
{
echo"</tr>";
}
else
{
echo "<td>";
}
}
echo"</tr></table>";
if($i==0)
{
echo "<strong><center><font color=red>ไม่มีรายการสินค้า</font></center></strong>";
}
?>
<hr width="98%" color="#f2f2f6">
<table width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" colspan="10" class="boxtext"><div align="center">จำนวน
<?=$Page;?>
หน้า <b>
<?=$Num_Pages;?>
</b> (
<?= $Num_Rows;?>
รายการ) </div></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="1" cellspacing="1" align="center">
<tr>
<td><div align="center">
<?/* สร้างปุ่มย้อนกลับ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page&CatID=$_GET[CatID]' class='boxtext'><< Back </a> ";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo " [ <a href='$PHP_SELF?Page=$i&CatID=$_GET[CatID]' class='boxtext'>$i</a> ]";
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo " <a href ='$PHP_SELF?Page=$Next_Page&CatID=$_GET[CatID]' class='boxtext'> Next >> </a>";
?>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td width="100%" height="16" align="center"> </td>
</tr>
</table>
</p></td>
</tr>
</table></td>
<td width="16%" valign="top"> <?php require_once('menuright.php'); ?> </td>
</tr>
<tr>
<td colspan="3" valign="top">
<?php require_once('down.php'); ?>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-08-10 15:51:07 |
By :
tormam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|