|
 |
|
อยากให้แสดงสินค้าว่าสินค้าหมด ถ้าจำนวนสินค้าในตราง มี จำนวนเป็น 0 |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
$id_type_select=$_GET[t_typeproductid];
$sql="select * from product where ref_id_type='$id_type_select'" ;
$result=mysql_db_query ($dbname,$sql);
$number = mysql_num_rows( $result);
$Per_Page = 4; // โชวทีละ4
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($number<=$Per_Page)
{
$Num_Pages =1;
}
else if(($number % $Per_Page)==0)
{
$Num_Pages =($number/$Per_Page) ;
}
else
{
$Num_Pages =($number/$Per_Page)+1;
$Num_Pages =(int)$Num_Pages;
}
$sql .="order by p_productid ASC LIMIT $Page_Start , $Per_Page";
$result= mysql_query($sql);
echo"<table border=\"0\" cellspacing=\"50\" cellpadding=\"50\"><tr>";
$intRows = 0;
while($rs=mysql_fetch_array($result)) {
echo "<td> ";
$intRows++;
?>
<center>
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'<width='20%' valign='top'>
<param name='movie' value='imageblythe/<?=$rs["p_picturename"];?>' />
<param name='quality' value='high' />
<embed src="imageblythe/<?=$rs["p_picturename"];?>" quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='40' height='50'></embed></object><br>
รหัสสินค้า ~ <?=$rs["p_productid"];?> ~<br>
ชื่อสินค้า ~ <?=$rs["p_name"];?> ~<br>
จำนวน ~ <?=$rs["p_amount"];?> ~<br>
ราคา ~ <?=$rs["p_price"];?> ~<br>
[<a href='prd_view2.php?p_productid=<?=$rs["p_productid"];?>'>แสดงรายละเอียด</a>]
<a href='imageblythe/<?=$rs["p_picturename"];?>' target='_blank'>[ขยาย]</a>
<a href='basket_add.php?p_productid=<?=$rs["p_productid"];?>'><img src="images/cart_icon.jpg" alt="ตะกร้าสินค้า"width="35" height="35"></a>
</center>
<?
echo"</td>";
if(($intRows)%2==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
<br>
จำนวนสินค้า <?= $number;?> แบบ : <?=$Num_Pages;?> หน้า :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?t_typeproductid=$id_type_select&Page=$Prev_Page'><< กลับ</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?t_typeproductid=$id_type_select&Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?t_typeproductid=$id_type_select&Page=$Next_Page'>ถัดไป>></a> ";
}
?>
<?
mysql_close();
?>
แทรกจำนวนเข้าไปแล้วคะ มะกี้ลืมใส่แล้วทำยังไงต่อคะ ให้จำนวนที่ เป้น 0 แสดงว่าสินค้าหมด
|
 |
 |
 |
 |
Date :
2011-03-27 00:55:54 |
By :
แนะนำทีคะ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
$id_type_select=$_GET[t_typeproductid];
$sql="select * from product where ref_id_type='$id_type_select'" ;
$result=mysql_db_query ($dbname,$sql);
$number = mysql_num_rows( $result);
if($number == 0)
{
echo "Found 0 Record";
}
else
{
$Per_Page = 4; // โชวทีละ4
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($number<=$Per_Page)
{
$Num_Pages =1;
}
else if(($number % $Per_Page)==0)
{
$Num_Pages =($number/$Per_Page) ;
}
else
{
$Num_Pages =($number/$Per_Page)+1;
$Num_Pages =(int)$Num_Pages;
}
$sql .="order by p_productid ASC LIMIT $Page_Start , $Per_Page";
$result= mysql_query($sql);
echo"<table border=\"0\" cellspacing=\"50\" cellpadding=\"50\"><tr>";
$intRows = 0;
while($rs=mysql_fetch_array($result)) {
echo "<td> ";
$intRows++;
?>
<center>
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'<width='20%' valign='top'>
<param name='movie' value='imageblythe/<?=$rs["p_picturename"];?>' />
<param name='quality' value='high' />
<embed src="imageblythe/<?=$rs["p_picturename"];?>" quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='40' height='50'></embed></object><br>
รหัสสินค้า ~ <?=$rs["p_productid"];?> ~<br>
ชื่อสินค้า ~ <?=$rs["p_name"];?> ~<br>
จำนวน ~ <?=$rs["p_amount"];?> ~<br>
ราคา ~ <?=$rs["p_price"];?> ~<br>
[<a href='prd_view2.php?p_productid=<?=$rs["p_productid"];?>'>แสดงรายละเอียด</a>]
<a href='imageblythe/<?=$rs["p_picturename"];?>' target='_blank'>[ขยาย]</a>
<a href='basket_add.php?p_productid=<?=$rs["p_productid"];?>'><img src="images/cart_icon.jpg" alt="ตะกร้าสินค้า"width="35" height="35"></a>
</center>
<?
echo"</td>";
if(($intRows)%2==0)
{
echo"</tr>";
}
}
echo"</tr></table>";
?>
<br>
จำนวนสินค้า <?= $number;?> แบบ : <?=$Num_Pages;?> หน้า :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?t_typeproductid=$id_type_select&Page=$Prev_Page'><< กลับ</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?t_typeproductid=$id_type_select&Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?t_typeproductid=$id_type_select&Page=$Next_Page'>ถัดไป>></a> ";
}
}
?>
<?
mysql_close();
?>
|
 |
 |
 |
 |
Date :
2011-03-27 10:44:46 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|