 |
ผู้รู้ช่วยดูโค๊ดการค้นหาให้หน่อยน๊ะค่ะ มัน ERROR อ่ะ |
|
 |
|
|
 |
 |
|
มัน ERROR แบบนี้นะค่ะ Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\Phpbasic\AnimalShop\tesbas.php on line 96
โค๊ดค่ะ
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>สินค้า</title>
<style type="text/css">
<!--
.style1 { font-size: large;
color: #0000FF;
}
.style3 {color: #0000FF}
.style4 {
color: #0000CC;
font-weight: bold;
font-size: x-large;
}
-->
</style>
</head>
<body>
<?
include"./include/connect.php";
?>
<table width="945" align="center">
<tr bgcolor="#FFFF66">
<td colspan="2" bgcolor="#C7FBBF"><div align="center" class="style1">
<p><img src="image/head.gif" width="973" height="200" /></p>
</div></td>
</tr>
<tr width="17" bordercolor="#000000" bgcolor="#000000">
<td width="22" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p>
<? include"menu.php"; ?>
</p>
</td>
<td width="911" height="460" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p align="center" class="style3"> </p>
<p align="center" class="style4">ค้นหาสินค้า</p>
<center>
<form id="form2" name="form2" method="post" action="tesbas.php">
<table width="546" border="0">
<tr>
<th width="214" scope="col">
<label>
ประเภทคำค้น
<select name="search" id="search">
<option value="1">ชื่อสินค้า</option>
<option value="2">ประเภทสินค้า</option>
<option value="3">ยี่ห้อสินค้า</option>
</select>
</label>
</th>
<th width="344" scope="col">
<label>
<input name="name" type="text" id="name" size="40" maxlength="40" />
</label>
<label>
<input type="submit" name="Submit" value="ค้นหา" />
</label>
</th>
</tr>
</table>
</form>
</center>
<p align="center" class="style4"> </p>
<p align="center" class="style4">ข้อมูลสินค้า</p>
<center> <table width="800" border="1" bordercolor="#00FF00" bgcolor="#FFFFFF">
<tr>
<th scope="row"><strong>รหัสสินค้า</strong></th>
<td><strong>ชื่อสินค้า</strong></td>
<td><strong>รายละเอียด</strong></td>
<td><strong>ราคาทุน</strong></td>
<td><strong>ราคาเงินสด</strong></td>
<td><strong>ราคาเงินเชื่อ</strong></td>
<td><strong>Min Stock</strong></td>
<td><strong>Max Stock </strong></td>
<td><strong>จำนวนคงเหลือ</strong></td>
<td><strong>หน่วย</strong></td>
<td><strong>ยี่ห้อ</strong></td>
<td><strong>ประเภท</strong></td>
<td> </td>
</tr>
<?
$n=0;
$name=$_POST[name];
if($_POST[search]==1){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
else if($_POST[search]==2){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pdt_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
else if($_POST[search]==3){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.bra_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row==""){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row<>0){
//while($read=mysql_fetch_array($result)){
$Per_Page = 5;
if ( !$Page) {
$Page = 1;
}
$Prev_Page =$Page- 1;
$Next_Page = $Page+ 1;
$result = mysql_db_query($db,$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 "จำนวน $Page มากกว่า $Num_Pages";
$sql .= " LIMIT $Page_start, $Per_Page";
$result = mysql_db_query($db,$sql);
if($Num_Rows<>0)
{
$num=0;
while($read= mysql_fetch_array($result)){
$num++;
$n++;
?>
<tr>
<th height="140" scope="row">
<div align="left">
<?=$read['pro_id']?>
</div></th>
<td>
<div align="left">
<?=$read['pro_name']?>
</div></td>
<td>
<div align="left">
<?=$read['pro_detail']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_cost']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_cash']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_credit']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_minstock']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_maxstock']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_stock']?>
</div></td><td><div align="left">
<?=$read['pro_unit']?>
</div></td>
<td>
<div align="left">
<?=$read['bra_name']?>
</div></td>
<td><div align="left">
<?=$read['pdt_name']?>
</div></td>
<td></a>
<div align="center">
<p><a href="editpro.php?pro_id=<?=$read['pro_id']?>">แก้ไข</a></p>
<p><a href="delpro.php?pro_id=<?=$read['pro_id']?>"onclick="return confirm('ยืนยันลบสินค้า<?=$read['pro_name']?>ออกจากระบบ')">ลบ</a></p></td>
</tr><? }?>
</table>
</center>
<? //แบ่งหน้า?>
<div align="center" >
มี <? echo $Num_Pages; ?> หน้า :
<?
/* สร้างปุ่มย้อนกลับ */
if ( $Prev_Page ){
echo "<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$Prev_Page\"><< ถอยหลัง </a>";
}
/* สร้างตัวเลขหน้า */
for ( $i=1; $i<=$Num_Pages; $i++ )
{
if ( $i != $Page )
echo "[<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$i\">$i</a>]";
else
echo " <b>$i</b> ";
}
/* สร้างปุ่มเดินหน้า */
if ( $Page != $Num_Pages ) {
echo "<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$Next_Page\"> เดินหน้า >></a>";
?>
<?
}//nums
}//while
?>
</div>
<?
//end select=================================================================
}else{?>
ไม่มีข้อมูล
<? }?>
<p align="center" class="style3"> </p>
<p> </p></td>
</tr>
</table>
</body>
</html>
Tag : PHP, Ms Access
|
|
 |
 |
 |
 |
Date :
2010-11-11 00:45:26 |
By :
dekcis |
View :
791 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
line 96 อยู่ตรงไหนครับ
|
 |
 |
 |
 |
Date :
2010-11-11 02:12:41 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มัน ERROR แบบนี้นะค่ะ Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\Phpbasic\AnimalShop\tesbas.php on line 96
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>สินค้า</title>
<style type="text/css">
<!--
.style1 { font-size: large;
color: #0000FF;
}
.style3 {color: #0000FF}
.style4 {
color: #0000CC;
font-weight: bold;
font-size: x-large;
}
-->
</style>
</head>
<body>
<?
include"./include/connect.php";
?>
<table width="945" align="center">
<tr bgcolor="#FFFF66">
<td colspan="2" bgcolor="#C7FBBF"><div align="center" class="style1">
<p><img src="image/head.gif" width="973" height="200" /></p>
</div></td>
</tr>
<tr width="17" bordercolor="#000000" bgcolor="#000000">
<td width="22" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p>
<? include"menu.php"; ?>
</p>
</td>
<td width="911" height="460" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p align="center" class="style3"> </p>
<p align="center" class="style4">ค้นหาสินค้า</p>
<center>
<form id="form2" name="form2" method="post" action="tesbas.php">
<table width="546" border="0">
<tr>
<th width="214" scope="col">
<label>
ประเภทคำค้น
<select name="search" id="search">
<option value="1">ชื่อสินค้า</option>
<option value="2">ประเภทสินค้า</option>
<option value="3">ยี่ห้อสินค้า</option>
</select>
</label>
</th>
<th width="344" scope="col">
<label>
<input name="name" type="text" id="name" size="40" maxlength="40" />
</label>
<label>
<input type="submit" name="Submit" value="ค้นหา" />
</label>
</th>
</tr>
</table>
</form>
</center>
<p align="center" class="style4"> </p>
<p align="center" class="style4">ข้อมูลสินค้า</p>
<center> <table width="800" border="1" bordercolor="#00FF00" bgcolor="#FFFFFF">
<tr>
<th scope="row"><strong>รหัสสินค้า</strong></th>
<td><strong>ชื่อสินค้า</strong></td>
<td><strong>รายละเอียด</strong></td>
<td><strong>ราคาทุน</strong></td>
<td><strong>ราคาเงินสด</strong></td>
<td><strong>ราคาเงินเชื่อ</strong></td>
<td><strong>Min Stock</strong></td>
<td><strong>Max Stock </strong></td>
<td><strong>จำนวนคงเหลือ</strong></td>
<td><strong>หน่วย</strong></td>
<td><strong>ยี่ห้อ</strong></td>
<td><strong>ประเภท</strong></td>
<td> </td>
</tr>
<?
$n=0;
$name=$_POST[name];
if($_POST[search]==1){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result); // line 96 ค่ะ
}
else if($_POST[search]==2){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pdt_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
else if($_POST[search]==3){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.bra_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row==""){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row<>0){
//while($read=mysql_fetch_array($result)){
$Per_Page = 5;
if ( !$Page) {
$Page = 1;
}
$Prev_Page =$Page- 1;
$Next_Page = $Page+ 1;
$result = mysql_db_query($db,$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 "จำนวน $Page มากกว่า $Num_Pages";
$sql .= " LIMIT $Page_start, $Per_Page";
$result = mysql_db_query($db,$sql);
if($Num_Rows<>0)
{
$num=0;
while($read= mysql_fetch_array($result)){
$num++;
$n++;
?>
<tr>
<th height="140" scope="row">
<div align="left">
<?=$read['pro_id']?>
</div></th>
<td>
<div align="left">
<?=$read['pro_name']?>
</div></td>
<td>
<div align="left">
<?=$read['pro_detail']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_cost']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_cash']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_credit']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_minstock']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_maxstock']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_stock']?>
</div></td><td><div align="left">
<?=$read['pro_unit']?>
</div></td>
<td>
<div align="left">
<?=$read['bra_name']?>
</div></td>
<td><div align="left">
<?=$read['pdt_name']?>
</div></td>
<td></a>
<div align="center">
<p><a href="editpro.php?pro_id=<?=$read['pro_id']?>">แก้ไข</a></p>
<p><a href="delpro.php?pro_id=<?=$read['pro_id']?>"onclick="return confirm('ยืนยันลบสินค้า<?=$read['pro_name']?>ออกจากระบบ')">ลบ</a></p></td>
</tr><? }?>
</table>
</center>
<? //แบ่งหน้า?>
<div align="center" >
มี <? echo $Num_Pages; ?> หน้า :
<?
/* สร้างปุ่มย้อนกลับ */
if ( $Prev_Page ){
echo "<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$Prev_Page\"><< ถอยหลัง </a>";
}
/* สร้างตัวเลขหน้า */
for ( $i=1; $i<=$Num_Pages; $i++ )
{
if ( $i != $Page )
echo "[<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$i\">$i</a>]";
else
echo " <b>$i</b> ";
}
/* สร้างปุ่มเดินหน้า */
if ( $Page != $Num_Pages ) {
echo "<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$Next_Page\"> เดินหน้า >></a>";
?>
<?
}//nums
}//while
?>
</div>
<?
//end select=================================================================
}else{?>
ไม่มีข้อมูล
<? }?>
<p align="center" class="style3"> </p>
<p> </p></td>
</tr>
</table>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-11-11 09:33:31 |
By :
dekcis |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_name link '%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
ผิดที่
link = LIKE
หรือไม่ก็ลอง echo $sql ออกมานำไปรันที่ phpmyadmin
|
 |
 |
 |
 |
Date :
2010-11-11 09:38:11 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณ Nico ค่ะ ลองแก้แล้วค่ะ แต่มันก้อ ERROR อีกค่ะ Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\Phpbasic\AnimalShop\tesbas.php on line 107
<?
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>สินค้า</title>
<style type="text/css">
<!--
.style1 { font-size: large;
color: #0000FF;
}
.style3 {color: #0000FF}
.style4 {
color: #0000CC;
font-weight: bold;
font-size: x-large;
}
-->
</style>
</head>
<body>
<?
include"./include/connect.php";
?>
<table width="945" align="center">
<tr bgcolor="#FFFF66">
<td colspan="2" bgcolor="#C7FBBF"><div align="center" class="style1">
<p><img src="image/head.gif" width="973" height="200" /></p>
</div></td>
</tr>
<tr width="17" bordercolor="#000000" bgcolor="#000000">
<td width="22" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p>
<? include"menu.php"; ?>
</p>
</td>
<td width="911" height="460" valign="top" bordercolor="#000000" bgcolor="#DBFFB7"><p align="center" class="style3"> </p>
<p align="center" class="style4">ค้นหาสินค้า</p>
<center>
<form id="form2" name="form2" method="post" action="tesbas.php">
<table width="546" border="0">
<tr>
<th width="214" scope="col">
<label>
ประเภทคำค้น
<select name="search" id="search">
<option value="1">ชื่อสินค้า</option>
<option value="2">ประเภทสินค้า</option>
<option value="3">ยี่ห้อสินค้า</option>
</select>
</label>
</th>
<th width="344" scope="col">
<label>
<input name="name" type="text" id="name" size="40" maxlength="40" />
</label>
<label>
<input type="submit" name="Submit" value="ค้นหา" />
</label>
</th>
</tr>
</table>
</form>
</center>
<p align="center" class="style4"> </p>
<p align="center" class="style4">ข้อมูลสินค้า</p>
<center> <table width="800" border="1" bordercolor="#00FF00" bgcolor="#FFFFFF">
<tr>
<th scope="row"><strong>รหัสสินค้า</strong></th>
<td><strong>ชื่อสินค้า</strong></td>
<td><strong>รายละเอียด</strong></td>
<td><strong>ราคาทุน</strong></td>
<td><strong>ราคาเงินสด</strong></td>
<td><strong>ราคาเงินเชื่อ</strong></td>
<td><strong>Min Stock</strong></td>
<td><strong>Max Stock </strong></td>
<td><strong>จำนวนคงเหลือ</strong></td>
<td><strong>หน่วย</strong></td>
<td><strong>ยี่ห้อ</strong></td>
<td><strong>ประเภท</strong></td>
<td> </td>
</tr>
<?
$n=0;
$name=$_POST[name];
if($_POST[search]==1){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_name like'%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
else if($_POST[search]==2){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pdt_name like'%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result); line 107
}
else if($_POST[search]==3){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.bra_name like'%$name%'
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row==""){
$sql="select pro_id,pro_name,pro_detail,pro_cost,pro_cash,pro_credit,pro_minstock,pro_maxstock,pro_stock,pro_unit,bra_name,pdt_name
From product,brand,producttype
WHERE brand.bra_id=product.bra_id
AND producttype.pdt_id=product.pdt_id
AND product.pro_status='Y'
GROUP BY pro_id";
$result=mysql_db_query($db,$sql);
$num_row=mysql_num_rows($result);
}
if($num_row<>0){
//while($read=mysql_fetch_array($result)){
$Per_Page = 5;
if ( !$Page) {
$Page = 1;
}
$Prev_Page =$Page- 1;
$Next_Page = $Page+ 1;
$result = mysql_db_query($db,$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 "จำนวน $Page มากกว่า $Num_Pages";
$sql .= " LIMIT $Page_start, $Per_Page";
$result = mysql_db_query($db,$sql);
if($Num_Rows<>0)
{
$num=0;
while($read= mysql_fetch_array($result)){
$num++;
$n++;
?>
<tr>
<th height="140" scope="row">
<div align="left">
<?=$read['pro_id']?>
</div></th>
<td>
<div align="left">
<?=$read['pro_name']?>
</div></td>
<td>
<div align="left">
<?=$read['pro_detail']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_cost']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_cash']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_credit']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_minstock']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_maxstock']?>
</div></td>
<td>
<div align="right">
<?=$read['pro_stock']?>
</div></td><td><div align="left">
<?=$read['pro_unit']?>
</div></td>
<td>
<div align="left">
<?=$read['bra_name']?>
</div></td>
<td><div align="left">
<?=$read['pdt_name']?>
</div></td>
<td></a>
<div align="center">
<p><a href="editpro.php?pro_id=<?=$read['pro_id']?>">แก้ไข</a></p>
<p><a href="delpro.php?pro_id=<?=$read['pro_id']?>"onclick="return confirm('ยืนยันลบสินค้า<?=$read['pro_name']?>ออกจากระบบ')">ลบ</a></p></td>
</tr><? }?>
</table>
</center>
<? //แบ่งหน้า?>
<div align="center" >
มี <? echo $Num_Pages; ?> หน้า :
<?
/* สร้างปุ่มย้อนกลับ */
if ( $Prev_Page ){
echo "<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$Prev_Page\"><< ถอยหลัง </a>";
}
/* สร้างตัวเลขหน้า */
for ( $i=1; $i<=$Num_Pages; $i++ )
{
if ( $i != $Page )
echo "[<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$i\">$i</a>]";
else
echo " <b>$i</b> ";
}
/* สร้างปุ่มเดินหน้า */
if ( $Page != $Num_Pages ) {
echo "<a href=\"$PHP_SELF?page=order_buy.php&num=$num++&Page=$Next_Page\"> เดินหน้า >></a>";
?>
<?
}//nums
}//while
?>
</div>
<?
//end select=================================================================
}else{?>
ไม่มีข้อมูล
<? }?>
<p align="center" class="style3"> </p>
<p> </p></td>
</tr>
</table>
</body>
</html>
|
 |
 |
 |
 |
Date :
2010-11-11 09:56:03 |
By :
dekcis |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองนำ Query String ไปลองทดสอบที่ตัว Database ดูก่อนนะครับว่า มีข้อมูลออกมาหรือไม่ ?
|
 |
 |
 |
 |
Date :
2010-11-11 16:06:31 |
By :
สุรชัย |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะนำให้ศึกษา การ query SQL ใหม่นะคะ ที่นี้นะคะ มีที่เราให้ได้หมดล่ะค่ะhttps://www.thaicreate.com/php/php-sql-syntax.html
|
 |
 |
 |
 |
Date :
2010-11-11 16:35:29 |
By :
penpimonmink |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกคนนะค่ะ ตอนนี้ำทำได้แล้วค่ะ พอดีผิดตรง SQL ค่ะ ขอบคุณมากๆๆๆๆๆนะค่ะ
|
 |
 |
 |
 |
Date :
2010-11-11 19:03:58 |
By :
dekcis |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|