|
 |
|
ช่วยดูโค้ดให้หน่อยอ่ะ โค้ดแบ่งหน้า มันไม่แบ่งอ่ะ แก้แล้วมันก็ไม่มีอะไรเกิดขึ้นอ่ะ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
$id_type_select=$_GET[id_type];
?>
<HTML>
<HEAD><TITLE>ร้านค้าออนไลน์</TITLE><meta http-equiv="Content-Type" content="text/html; charset=windows-874"><style type="text/css">
<!--
body {
background-image: url(image/reply-00000028820.gif);
}
-->
</style></HEAD>
<BODY>
<H2>:: ร้านค้าออนไลน์ ::</H2>
<P>
[ <A HREF="index.php">หน้าแรก</A> ]
[ <A HREF="basket.php">ดูตะกร้าสินค้า</A> ] </P>
<TABLE WIDTH="878" height="213" BORDER="0" align="center">
<TR>
<TD WIDTH="253" HEIGHT="200" VALIGN="top" BGCOLOR="#FF99FF">
<br><br><br>
<CENTER><B>ประเภทสินค้า</B></CENTER>
<?
include "connect.php";
include "type_list.php";
?>
<BR />
<br />
<a href="payment_a.php">ค่าขนส่ง</a><br />
<a href="slip_th.php">แจ้งการขนส่ง</a>
<BR />
<br />
<a href="admin_logout.php"> ออกจากระบบ</a>
</TD>
<TD WIDTH="615" VALIGN="top" bgcolor="#FF99FF"><div align="center">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="4">
<br><br><br>
<?php
require_once("connect.php");
$psize = 10;
$page = $_GET["page"];
if(empty($page)){ $page=1; }
if(!is_numeric($page)){ $page=1; }
$sql_cnt = "select code, name_prd, price, id_prd from tb_product";
$query_cnt = @mysql_query($sql_cnt);
$num_total = @mysql_num_rows($query_cnt);
$total_page = ceil($num_total / $psize);
$bgin = ($page-1) * $psize;
$sql = "select code, name_prd, price, id_prd from tb_product LIMIT $bgin, $psize";
$query = mysql_query($sql);
?>
<?
$sql="select * from tb_product where ref_id_type='$id_type_select'order by id_prd asc ";
$result=mysql_db_query($dbname,$sql);
while ($rs=mysql_fetch_array($result)) {
$id_prd=$rs[id_prd];
$code=sprintf("%05d",$id_prd);
$name_prd=$rs[name_prd];
$detail_prd=$rs[detail_prd];
$ref_id_type=$rs[ref_id_type];
$price_prd=$rs[price_prd];
echo "<TR>
<TD WIDTH='80%' VALIGN='top'>
<B>รหัสสินค้า :</B> $code <BR>
<B>ชื่อสินค้า : </B>$name_prd <BR>
<B>ราคา :</B> $price_prd บาท<BR>
[ <A HREF='basket_add.php?id_prd=$id_prd'>ซื้อสินค้า </A>] <BR> <BR>
</TD>
</TR>";
}
?>
</TABLE>
<?php
if($page > 1){
$back = $page - 1;
echo "<a href=$PHP_SELF?page=1><<หน้าแรก </a>| ";
echo "<a href=$PHP_SELF?page=".$back."><กลับ </a>| ";
}
for($i=1;$i<=$total_page;$i++){
if($i==$page){
echo "<font color='red'><b>[".$i."]</b></font> ";
}else{
echo "<a href=$PHP_SELF?page=".$i.">".$i."</a> ";
}
}
if($page < $total_page){
$next = $page + 1;
echo "| <a href=$PHP_SELF?page=".$next.">ถัดไป></a> | ";
echo "<a href=$PHP_SELF?page=".$total_page.">หน้าสุดท้าย>></a>";
}
?>
</BODY>
</HTML>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-06-24 18:49:17 |
By :
blooka |
View :
825 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สองบรรทัดนี้
$query_cnt = @mysql_query($sql_cnt);
$num_total = @mysql_num_rows($query_cnt);
เอา @ ออกก่อนครับ มันปิด Error ไว้ เลยมองไม่เห็นว่า Error อะไร
|
 |
 |
 |
 |
Date :
2011-06-24 19:14:23 |
By :
adaaugusta |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่ะ
เออเร่อ ตรงนี้อ่ะ
$num_total = @mysql_num_rows($query_cnt);
|
 |
 |
 |
 |
Date :
2011-06-24 20:24:24 |
By :
blooka |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเปลี่ยนบรรทัด
$query_cnt = @mysql_query($sql_cnt);
เป็น $query_cnt = mysql_db_query($dbname,$sql_cnt);
ดูครับ
|
 |
 |
 |
 |
Date :
2011-06-24 21:38:36 |
By :
adaaugusta |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|