  | 
              
	              
	                
  
    
	 
        ช่วยดูโค้ดphp การแบ่งหน้าให้หน่อยค่ะ มันมีปัญหาค่ะ สินค้าออกมาหมด     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                ช่วยดูโค้ดแบ่งหน้าให้หน่อยค่ะ 
 
คือในตารางสินค้ามีสินค้า 10 ชิ้น 
 
หนูกำหนดว่า ให้เลือกแสดงสินค้าเฉพาะประเภททั่วไป (ตัวแปรคือ 1) ตัวนี้มันดึงมาถูกแล้วค่ะ มีอยู่ 7 ชิ้น 
 
แล้วให้แสดงหน้าละ 3 ชิ้น  แต่มันกลับแสดง  21 ชิ้นอ่าค่ะ คือ เอาสินค้าทั่วไปที่มี 7 ชิ้นมาแสดง ซ้ำ 3 ครั้ง 
 
ที่ต้องการให้ออกคือ หน้าละ 3 ชิ้น 
 
สินค้าชิ้นที่1 
สินค้าชิ้นที่2 
สินค้าชิ้นที่3 
 
 
แต่มันออกเป็นแบบนี้อ่ะค่ะ เอามาแสดงต่อกัน 3 ครั้ง 
สินค้าชิ้นที่1 
สินค้าชิ้นที่2 
สินค้าชิ้นที่3 
สินค้าชิ้นที่4 
สินค้าชิ้นที่5 
สินค้าชิ้นที6 
สินค้าชิ้นที่7 
 
สินค้าชิ้นที่1 
สินค้าชิ้นที่2 
สินค้าชิ้นที่3 
สินค้าชิ้นที่4 
สินค้าชิ้นที่5 
สินค้าชิ้นที6 
สินค้าชิ้นที่7 
 
สินค้าชิ้นที่1 
สินค้าชิ้นที่2 
สินค้าชิ้นที่3 
สินค้าชิ้นที่4 
สินค้าชิ้นที่5 
สินค้าชิ้นที6 
สินค้าชิ้นที่7 
 
แต่ถ้าเราตัด3 บรรทัดนี้ออก มันแบ่งได้ถูกแต่ สินค้าไม่แสดงค่ะ 
$sql="select * from product where type_id='$id_type_select'"; 
$result=mysql_db_query($dbname,$sql); 
while($rs=mysql_fetch_array($result)){ 
 
 
นี่โค้ดทั้งหมดค่ะ 
<?php 
require("auth.inc.php"); 
$id_type_select=$_GET[id_type]=1; 
?> 
 
<?php  
function page_navi($page, $limit, $range, $count, $target="_self", $current_style="", $other_style="", $quetystring=""){  
$total = ceil($count/$limit);  
$navi_start = $page-$range;  
$navi_end = $page+$range;  
 
$send = !empty($querystring)? "&". $querystring : "";  
 
if($navi_start <= 0) $navi_start = 1;  
if($navi_end >= $total) $navi_end = $total;  
if($page>1){  
$navi_back = $page-1;  
if($page > 2)  
echo "<a href=\"?page=1" . $send . "\" target=\"" . $target . "\">«</a> ";  
echo "<a href=\"?page=$navi_back" . $send . "\" target=\"" . $target . "\">‹</a> ";  
}  
for($i = $navi_start; $i <= $navi_end; $i++){  
if($i == $page)  
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\"><strong>$i</strong></a> ";  
else  
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\">$i</a> ";  
}  
if($page < $total){  
$navi_next = $page+1;  
echo "<a href=\"?page=$navi_next" . $send . "\" target=\"" . $target . "\">›</a> ";  
if(($page+1) < $total)  
echo "<a href=\"?page=$total" . $send . "\" target=\"" . $target . "\">»</a>";  
}  
}  
?>  
 
<!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=utf-8" /> 
<title>ร้านบีบุค ทู แฮนด์</title> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
</head> 
 
<body onload="document.a.username.focus();"> 
<div id="templatemo_container"> 
	<div id="templatemo_header"></div>  
<!-- end of header --> 
     
    <div id="templatemo_menu"> 
        <ul> 
            <li><a href="index2.php" class="current">หน้าแรก</a></li> 
			<li><a href="index2.php">รายการสินค้า</a></li> 
            <li><a href="basket.php">ตะกร้าสินค้า</a></li> 
            <li><a href="cus_order_detail.php">ใบสั่งซื้อ</a></li> 
		    <li><a href="payform.php">แจ้งการโอนเงิน</a></li> 
            <li><a href="bbook6.php">กระบวนการสั่งซื้อ</a></li> 
             <li><a href="bbook8.php" class="last">ติดต่อ</a></li> 
        </ul>      	 
    </div> <!-- end of menu --> 
 
     
    <div id="templatemo_content"> 
         
        <div id="content_left"> 
         
         <div class="content_left_section"> 
            	<div class="content_left_section_title">ข้อมูลการเข้าระบบ</div> 
				<div class="content_left_section_content2"> 
                     <Form action="login.php" method=post name=a> 
<center> 
<TABLE> 
<tr><td> 
<?php 
require("auth.inc.php"); 
echo "<center>Welcome <b>" . $_SESSION['ses_user'] . "</b><br>";  
echo " Login เข้ามาล่าสุดเมื่อ <b>" . $_SESSION['last_log'] . "</b>";  
?> 
</td></tr></TABLE></center> 
</form> 
<center><br><a href=updateform.php>แก้ไขข้อมูลส่วนตัว</a> <br> 
            <a href=logoff.php>ออกจากระบบ</a></center><br> 
 
                    <div class="cleaner"> </div> 
                </div>	 
                <div class="cleaner"> </div> 
            	<div class="content_left_section_bottom"> </div> 
            </div> 
             
            <div class="margin_bottom_20"> </div> 
        	<div class="content_left_section"> 
 
            <div class="content_left_section_title">ประเภทสินค้า</div> 
				<div class="content_left_section_content"> 
                	<?php	include"connect.php"; 
				include"type_list.php"; 
		?>   
                </div> 
	 
            	<div class="content_left_section_bottom"> </div> 
            </div> 
             
            <div class="margin_bottom_20"> </div> 
             
 
 
            <div class="content_left_section"> 
            	<div class="content_left_section_title">ตรวจสอบการจัดส่งสินค้า</div> 
   	  <div class="content_left_section_content"> 
                        <a href="http://track.thailandpost.com/trackinternet/Default.aspx?lang=th"><img style="border:0;width:160px;height:40px" src="images/logopost.jpg" alt="logopost" width="120" height="35" vspace="8" border="0" /></a> 
                    </div>                     
	                <div class="cleaner"> </div> 
                    <div class="content_left_section_bottom"> </div> 
            </div> 
             
            <div class="margin_bottom_20"> </div> 
             
            <div class="content_left_section_ad"> 
            	<img src="images/templatemo_ad.jpg" alt="image" /> 
            </div> 
             
        </div> <!-- end of content left --> 
 
 
         
		<div id="content_right"> 
         
            <div class="right_col_section_w650"> 
     
                <div class="header_01">รายการสินค้า</div> 
             
<?php	include"connect.php";?> 
			<td> 
			<table width="100%" broder="0" cellspacing="4"> 
 
<?php  
 
$hostNameDB = "localhost"; 
$userNameDB = "root"; 
$passWordDB = "root"; 
//$conn = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);  
$conn = mysql_connect($hostNameDB, $userNameDB, $passWordDB) or die ("Cannot connect to Server or connect db_cmpdurable Database"); 
 
mysql_query("SET NAMES utf8", $conn);  
mysql_query("USE db_listmenu"); 
 
$page = (isset($_GET['page']))? intval($_GET['page']) : 1;  
$limit_end = 3;  
$limit_start = ($page-1)*$limit_end;  
 
$send = "";  
if(isset($_GET["id"]) and $_GET["id"] != ""){  
$send = "id=" . $_GET["id"];  
$condition= " WHERE pro_id = '" . $_GET["id"] . "'";  
}  
 
$sql = "SELECT * FROM product". $condition;  
$query_id = mysql_query($sql . " LIMIT " . $limit_start. "," . $limit_end, $conn);  
$count = mysql_num_rows($query_id);  
$total = mysql_num_rows(mysql_query($sql, $conn));  
if($total > 0){  
while($rows = mysql_fetch_assoc($query_id)){  
echo $rows[""];  
//**************************************** 
              
			 
				 
			 
			$sql="select * from product where type_id='$id_type_select'"; 
			$result=mysql_db_query($dbname,$sql); 
			while($rs=mysql_fetch_array($result)){ 
				$id_pro=$rs[pro_id]; 
				$code=sprintf("%05d",$id_pro); 
				$name_pro=$rs[pro_name]; 
				$detail_pro=$rs[pro_detail]; 
				$ref_id_type=$rs[type_id]; 
                $price_pro=$rs[pro_price]; 
			    $photo_pro=$rs[pro_photo]; 
				if($photo_pro==""){$photo_pro="temp.jpg";} 
echo"<tr> 
			<td width='20%' valign='top'> <img src='imgProduct/$photo_pro'></td> 
            <td width='80%' valign='top'><b>รหัสสินค้า :</b> $code<br> 
										 <b>ชื่อสินค้า :</b> $name_pro<br> 
										 <b>ราคา :</b> $price_pro บาท<br><br> 
					[<a href='product_view.php?id_pro=$id_pro'>แสดงรายละเอียด</a>] 
					[<a href='basket_add.php?id_pro=$id_pro'>หยิบใส่ตะกร้า</a>]<br><br><br><br> 
			</td> 
		</tr>"; 
			}  
			 
 
 
//******************************************* 
 
 
 
}  
echo "\n<div style=\"float:left;\">Page : " . page_navi($page, $limit_end, 3, $total, "current_page","other_page",$send) . " </div><div style=\"float:right;\">[" . ($limit_start+1) . "-" . ($limit_start+$count) . "] of <strong>" . $total . "</strong></div>";  
}  
?>  
 
 
            
          </div> 
 
 
        <div class="margin_bottom_20"> </div> 
 
                                                 
                <div class="margin_bottom_20"> </div> 
                 
            </div> <!-- end of right_col_section_w220 --> 
             
        </div> <!-- end of content right --> 
         
        <div class="cleaner"> </div> 
	</div> <!-- end of container --> 
 
<!--  Free CSS Templates by www.TemplateMo.com  --> 
     
</div> <!-- end of container --> 
</body> 
</html>
 
 
  Tag : PHP, MySQL               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2011-02-15 22:35:23 | 
                      By :
                          nu | 
                      View :
                          1819 | 
                      Reply :
                          18 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 เดาว่าคงต้องแ้ก้เป็นแบบนี้ 
 
Code (PHP) 
<?php
require("auth.inc.php");
$id_type_select=$_GET[id_type]=1;
?>
<?php
function page_navi($page, $limit, $range, $count, $target="_self", $current_style="", $other_style="", $quetystring=""){
$total = ceil($count/$limit);
$navi_start = $page-$range;
$navi_end = $page+$range;
$send = !empty($querystring)? "&". $querystring : "";
if($navi_start <= 0) $navi_start = 1;
if($navi_end >= $total) $navi_end = $total;
if($page>1){
$navi_back = $page-1;
if($page > 2)
echo "<a href=\"?page=1" . $send . "\" target=\"" . $target . "\">«</a> ";
echo "<a href=\"?page=$navi_back" . $send . "\" target=\"" . $target . "\">‹</a> ";
}
for($i = $navi_start; $i <= $navi_end; $i++){
if($i == $page)
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\"><strong>$i</strong></a> ";
else
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\">$i</a> ";
}
if($page < $total){
$navi_next = $page+1;
echo "<a href=\"?page=$navi_next" . $send . "\" target=\"" . $target . "\">›</a> ";
if(($page+1) < $total)
echo "<a href=\"?page=$total" . $send . "\" target=\"" . $target . "\">»</a>";
}
}
?>
<!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=utf-8" />
<title>ร้านบีบุค ทู แฮนด์</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body onload="document.a.username.focus();">
<div id="templatemo_container">
<div id="templatemo_header"></div>
<!-- end of header -->
<div id="templatemo_menu">
<ul>
<li><a href="index2.php" class="current">หน้าแรก</a></li>
<li><a href="index2.php">รายการสินค้า</a></li>
<li><a href="basket.php">ตะกร้าสินค้า</a></li>
<li><a href="cus_order_detail.php">ใบสั่งซื้อ</a></li>
<li><a href="payform.php">แจ้งการโอนเงิน</a></li>
<li><a href="bbook6.php">กระบวนการสั่งซื้อ</a></li>
<li><a href="bbook8.php" class="last">ติดต่อ</a></li>
</ul>
</div> <!-- end of menu -->
<div id="templatemo_content">
<div id="content_left">
<div class="content_left_section">
<div class="content_left_section_title">ข้อมูลการเข้าระบบ</div>
<div class="content_left_section_content2">
<Form action="login.php" method=post name=a>
<center>
<TABLE>
<tr><td>
<?php
require("auth.inc.php");
echo "<center>Welcome <b>" . $_SESSION['ses_user'] . "</b><br>";
echo " Login เข้ามาล่าสุดเมื่อ <b>" . $_SESSION['last_log'] . "</b>";
?>
</td></tr></TABLE></center>
</form>
<center><br><a href=updateform.php>แก้ไขข้อมูลส่วนตัว</a> <br>
<a href=logoff.php>ออกจากระบบ</a></center><br>
<div class="cleaner"> </div>
</div>
<div class="cleaner"> </div>
<div class="content_left_section_bottom"> </div>
</div>
<div class="margin_bottom_20"> </div>
<div class="content_left_section">
<div class="content_left_section_title">ประเภทสินค้า</div>
<div class="content_left_section_content">
<?php include"connect.php";
include"type_list.php";
?>
</div>
<div class="content_left_section_bottom"> </div>
</div>
<div class="margin_bottom_20"> </div>
<div class="content_left_section">
<div class="content_left_section_title">ตรวจสอบการจัดส่งสินค้า</div>
<div class="content_left_section_content">
<a href="http://track.thailandpost.com/trackinternet/Default.aspx?lang=th"><img style="border:0;width:160px;height:40px" src="images/logopost.jpg" alt="logopost" width="120" height="35" vspace="8" border="0" /></a>
</div>
<div class="cleaner"> </div>
<div class="content_left_section_bottom"> </div>
</div>
<div class="margin_bottom_20"> </div>
<div class="content_left_section_ad">
<img src="images/templatemo_ad.jpg" alt="image" />
</div>
</div> <!-- end of content left -->
<div id="content_right">
<div class="right_col_section_w650">
<div class="header_01">รายการสินค้า</div>
<?php include"connect.php";?>
<td>
<table width="100%" broder="0" cellspacing="4">
<?php
$hostNameDB = "localhost";
$userNameDB = "root";
$passWordDB = "root";
//$conn = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
$conn = mysql_connect($hostNameDB, $userNameDB, $passWordDB) or die ("Cannot connect to Server or connect db_cmpdurable Database");
mysql_query("SET NAMES utf8", $conn);
mysql_query("USE db_listmenu");
$page = (isset($_GET['page']))? intval($_GET['page']) : 1;
$limit_end = 3;
$limit_start = ($page-1)*$limit_end;
$send = "";
if(isset($_GET["id_type"]) and $_GET["id_type"] != ""){
$send = "id_type=" . $_GET["id_type"];
$condition= " WHERE type_id = '" . $_GET["id_type"] . "'";
}
$sql = "SELECT * FROM product". $condition;
$query_id = mysql_query($sql . " LIMIT " . $limit_start. "," . $limit_end, $conn);
$count = mysql_num_rows($query_id);
$total = mysql_num_rows(mysql_query($sql, $conn));
if($total > 0){
while($rs = mysql_fetch_assoc($query_id)){
$id_pro=$rs[pro_id];
$code=sprintf("%05d",$id_pro);
$name_pro=$rs[pro_name];
$detail_pro=$rs[pro_detail];
$ref_id_type=$rs[type_id];
$price_pro=$rs[pro_price];
$photo_pro=$rs[pro_photo];
if($photo_pro==""){$photo_pro="temp.jpg";}
echo"<tr>
<td width='20%' valign='top'> <img src='imgProduct/$photo_pro'></td>
<td width='80%' valign='top'><b>รหัสสินค้า :</b> $code<br>
<b>ชื่อสินค้า :</b> $name_pro<br>
<b>ราคา :</b> $price_pro บาท<br><br>
[<a href='product_view.php?id_pro=$id_pro'>แสดงรายละเอียด</a>]
[<a href='basket_add.php?id_pro=$id_pro'>หยิบใส่ตะกร้า</a>]<br><br><br><br>
</td>
</tr>";
}
echo "\n<div style=\"float:left;\">Page : " . page_navi($page, $limit_end, 3, $total, "current_page","other_page",$send) . " </div><div style=\"float:right;\">[" . ($limit_start+1) . "-" . ($limit_start+$count) . "] of <strong>" . $total . "</strong></div>";
}
?>
</div>
<div class="margin_bottom_20"> </div>
<div class="margin_bottom_20"> </div>
</div> <!-- end of right_col_section_w220 -->
</div> <!-- end of content right -->
<div class="cleaner"> </div>
</div> <!-- end of container -->
<!-- Free CSS Templates by www.TemplateMo.com -->
</div> <!-- end of container -->
</body>
</html>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-15 23:09:20 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ขอบคุณนะคะ เดี๋ยวลองเอาไปทำดูค่ะ ^^                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-16 13:30:42 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 แล้วถ้าในกรณีที่แบ่งหน้าตารางแบบนี้ล่ะค่ะ 
 
  
 
 
มันไม่แสดงข้อมูล  แต่การแบ่งหน้าถูกหมดแล้วค่ะ 
 
 
 
โค้ดค่ะ 
 
<?php 
require("auth.inc.php"); 
$id_cus=$_GET[id_cus]; 
?> 
 
<?php 
function page_navi($page, $limit, $range, $count, $target="_self", $current_style="", $other_style="", $quetystring=""){ 
$total = ceil($count/$limit); 
$navi_start = $page-$range; 
$navi_end = $page+$range; 
 
$send = !empty($querystring)? "&". $querystring : ""; 
 
if($navi_start <= 0) $navi_start = 1; 
if($navi_end >= $total) $navi_end = $total; 
if($page>1){ 
$navi_back = $page-1; 
if($page > 2) 
echo "<a href=\"?page=1" . $send . "\" target=\"" . $target . "\">«</a> "; 
echo "<a href=\"?page=$navi_back" . $send . "\" target=\"" . $target . "\">‹</a> "; 
} 
for($i = $navi_start; $i <= $navi_end; $i++){ 
if($i == $page) 
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\"><strong>$i</strong></a> "; 
else 
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\">$i</a> "; 
} 
if($page < $total){ 
$navi_next = $page+1; 
echo "<a href=\"?page=$navi_next" . $send . "\" target=\"" . $target . "\">›</a> "; 
if(($page+1) < $total) 
echo "<a href=\"?page=$total" . $send . "\" target=\"" . $target . "\">»</a>"; 
} 
} 
?> 
 
<!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=utf-8" /> 
<title>ร้านบีบุค ทู แฮนด์</title> 
<link href="style.css" rel="stylesheet" type="text/css" /> 
</head> 
 
<body onload="document.a.username.focus();"> 
<div id="templatemo_container"> 
<div id="templatemo_header"></div> 
<!-- end of header --> 
 
<div id="templatemo_menu"> 
<ul> 
<li><a href="index2.php" class="current">หน้าแรก</a></li> 
<li><a href="index2.php">รายการสินค้า</a></li> 
<li><a href="basket.php">ตะกร้าสินค้า</a></li> 
<li><a href="cus_order_detail.php">ใบสั่งซื้อ</a></li> 
<li><a href="payform.php">แจ้งการโอนเงิน</a></li> 
<li><a href="bbook6.php">กระบวนการสั่งซื้อ</a></li> 
<li><a href="bbook8.php" class="last">ติดต่อ</a></li> 
</ul> 
</div> <!-- end of menu --> 
 
 
<div id="templatemo_content"> 
 
<div id="content_left"> 
 
<div class="content_left_section"> 
<div class="content_left_section_title">ข้อมูลการเข้าระบบ</div> 
<div class="content_left_section_content2"> 
<Form action="login.php" method=post name=a> 
<center> 
<TABLE> 
<tr><td> 
<?php 
require("auth.inc.php"); 
echo "<center>Welcome <b>" . $_SESSION['ses_user'] . "</b><br>"; 
echo " Login เข้ามาล่าสุดเมื่อ <b>" . $_SESSION['last_log'] . "</b>"; 
?> 
</td></tr></TABLE></center> 
</form> 
<center><br><a href=updateform.php>แก้ไขข้อมูลส่วนตัว</a> <br> 
<a href=logoff.php>ออกจากระบบ</a></center><br> 
 
<div class="cleaner"> </div> 
</div> 
<div class="cleaner"> </div> 
<div class="content_left_section_bottom"> </div> 
</div> 
 
<div class="margin_bottom_20"> </div> 
<div class="content_left_section"> 
 
<div class="content_left_section_title">ประเภทสินค้า</div> 
<div class="content_left_section_content"> 
<?php include"connect.php"; 
include"type_list.php"; 
?> 
</div> 
 
<div class="content_left_section_bottom"> </div> 
</div> 
 
<div class="margin_bottom_20"> </div> 
 
 
 
<div class="content_left_section"> 
<div class="content_left_section_title">ตรวจสอบการจัดส่งสินค้า</div> 
<div class="content_left_section_content"> 
<a href="http://track.thailandpost.com/trackinternet/Default.aspx?lang=th"><img style="border:0;width:160px;height:40px" src="images/logopost.jpg" alt="logopost" width="120" height="35" vspace="8" border="0" /></a> 
</div> 
<div class="cleaner"> </div> 
<div class="content_left_section_bottom"> </div> 
</div> 
 
<div class="margin_bottom_20"> </div> 
 
<div class="content_left_section_ad"> 
<img src="images/templatemo_ad.jpg" alt="image" /> 
</div> 
 
</div> <!-- end of content left --> 
 
 
 
<div id="content_right"> 
 
<div class="right_col_section_w650"> 
 
<div class="header_01">รายการสินค้า</div> 
 
<?php include"connect.php";?> 
<td> 
<table width="100%" broder="0" cellspacing="4"> 
 
<?php 
 
$hostNameDB = "localhost"; 
$userNameDB = "root"; 
$passWordDB = "root"; 
//$conn = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); 
$conn = mysql_connect($hostNameDB, $userNameDB, $passWordDB) or die ("Cannot connect to Server or connect db_cmpdurable Database"); 
 
mysql_query("SET NAMES utf8", $conn); 
mysql_query("USE db_listmenu"); 
 
$page = (isset($_GET['page']))? intval($_GET['page']) : 1; 
$limit_end = 3; 
$limit_start = ($page-1)*$limit_end; 
 
$send = ""; 
if(isset($_GET["id_cus"]) and $_GET["id_cus"] != ""){ 
$send = "id_cus=" . $_GET["id_cus"]; 
$condition= " WHERE cus_id = '" . $_GET["id_cus"] . "'"; 
} 
 
$sql = "SELECT * FROM tbuser". $condition; 
$query_id = mysql_query($sql . " LIMIT " . $limit_start. "," . $limit_end, $conn); 
$count = mysql_num_rows($query_id); 
$total = mysql_num_rows(mysql_query($sql, $conn)); 
if($total > 0){ 
while($rs = mysql_fetch_assoc($query_id)){ 
$id_cus = $rs[cus_id]; 
						$code_cus = sprintf("%05d",$id_cus); 
						$fname_cus = $rs[cus_fname]; 
						$lname_cus = $rs[cus_lname]; 
						$msg = $rs[msg]; 
						$tel_cus = $rs[cus_tel]; 
						$email_cus = $rs[cus_email]; 
echo"<tr> 
					<td><center><?=$no?></center></td> 
					<td><?=$id_cus?></td> 
					<td><?=$fname_cus?></td> 
					<td><?=$lname_cus?></td> 
					<td><?=$msg?></td> 
					<td><?=$tel_cus?></td> 
					<td><?=$email_cus?></td> 
					</tr> 
					<? 
					$no++;	 
					} 
				?>"; 
} 
echo "\n<div style=\"float:left;\">Page : " . page_navi($page, $limit_end, 3, $total, "current_page","other_page",$send) . " </div><div style=\"float:right;\">[" . ($limit_start+1) . "-" . ($limit_start+$count) . "] of <strong>" . $total . "</strong></div>"; 
} 
?> 
 
 
 
 
</div> 
 
 
<div class="margin_bottom_20"> </div> 
 
 
<div class="margin_bottom_20"> </div> 
 
</div> <!-- end of right_col_section_w220 --> 
 
</div> <!-- end of content right --> 
 
<div class="cleaner"> </div> 
</div> <!-- end of container --> 
 
<!-- Free CSS Templates by www.TemplateMo.com --> 
 
</div> <!-- end of container --> 
</body> 
</html> 
 
 
 
 
แล้วถ้ากรณีที่ แบ่งข้อมูลตารางแบบนี้  แต่มีการดึงมาจากฐานข้อมูล หลายที่ละค่ะ 
เช่น ตารางสินค้า มีการดึงจากตารางประเภทมาด้วยอ่าค่ะ ต้องแก้ไขดึงค่ามายังไงค่ะ 
 
ขอบคุณพี่มากๆๆๆๆนะค่ะ 
 
^^                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-17 14:19:01 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ช่วยครอบ php code ให้ด้วยครับ ตาลาย                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-17 15:50:22 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
<?php
require("auth.inc.php");
$id_cus=$_GET[id_cus];
?>
<?php
function page_navi($page, $limit, $range, $count, $target="_self", $current_style="", $other_style="", $quetystring=""){
$total = ceil($count/$limit);
$navi_start = $page-$range;
$navi_end = $page+$range;
$send = !empty($querystring)? "&". $querystring : "";
if($navi_start <= 0) $navi_start = 1;
if($navi_end >= $total) $navi_end = $total;
if($page>1){
$navi_back = $page-1;
if($page > 2)
echo "<a href=\"?page=1" . $send . "\" target=\"" . $target . "\">«</a> ";
echo "<a href=\"?page=$navi_back" . $send . "\" target=\"" . $target . "\">‹</a> ";
}
for($i = $navi_start; $i <= $navi_end; $i++){
if($i == $page)
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\"><strong>$i</strong></a> ";
else
echo "<a href=\"?page=$i" . $send . "\" target=\"" . $target . "\">$i</a> ";
}
if($page < $total){
$navi_next = $page+1;
echo "<a href=\"?page=$navi_next" . $send . "\" target=\"" . $target . "\">›</a> ";
if(($page+1) < $total)
echo "<a href=\"?page=$total" . $send . "\" target=\"" . $target . "\">»</a>";
}
}
?>
<!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=utf-8" />
<title>ร้านบีบุค ทู แฮนด์</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body onload="document.a.username.focus();">
<div id="templatemo_container">
<div id="templatemo_header"></div>
<!-- end of header -->
<div id="templatemo_menu">
<ul>
<li><a href="index2.php" class="current">หน้าแรก</a></li>
<li><a href="index2.php">รายการสินค้า</a></li>
<li><a href="basket.php">ตะกร้าสินค้า</a></li>
<li><a href="cus_order_detail.php">ใบสั่งซื้อ</a></li>
<li><a href="payform.php">แจ้งการโอนเงิน</a></li>
<li><a href="bbook6.php">กระบวนการสั่งซื้อ</a></li>
<li><a href="bbook8.php" class="last">ติดต่อ</a></li>
</ul>
</div> <!-- end of menu -->
<div id="templatemo_content">
<div id="content_left">
<div class="content_left_section">
<div class="content_left_section_title">ข้อมูลการเข้าระบบ</div>
<div class="content_left_section_content2">
<Form action="login.php" method=post name=a>
<center>
<TABLE>
<tr><td>
<?php
require("auth.inc.php");
echo "<center>Welcome <b>" . $_SESSION['ses_user'] . "</b><br>";
echo " Login เข้ามาล่าสุดเมื่อ <b>" . $_SESSION['last_log'] . "</b>";
?>
</td></tr></TABLE></center>
</form>
<center><br><a href=updateform.php>แก้ไขข้อมูลส่วนตัว</a> <br>
<a href=logoff.php>ออกจากระบบ</a></center><br>
<div class="cleaner"> </div>
</div>
<div class="cleaner"> </div>
<div class="content_left_section_bottom"> </div>
</div>
<div class="margin_bottom_20"> </div>
<div class="content_left_section">
<div class="content_left_section_title">ประเภทสินค้า</div>
<div class="content_left_section_content">
<?php include"connect.php";
include"type_list.php";
?>
</div>
<div class="content_left_section_bottom"> </div>
</div>
<div class="margin_bottom_20"> </div>
<div class="content_left_section">
<div class="content_left_section_title">ตรวจสอบการจัดส่งสินค้า</div>
<div class="content_left_section_content">
<a href="http://track.thailandpost.com/trackinternet/Default.aspx?lang=th"><img style="border:0;width:160px;height:40px" src="images/logopost.jpg" alt="logopost" width="120" height="35" vspace="8" border="0" /></a>
</div>
<div class="cleaner"> </div>
<div class="content_left_section_bottom"> </div>
</div>
<div class="margin_bottom_20"> </div>
<div class="content_left_section_ad">
<img src="images/templatemo_ad.jpg" alt="image" />
</div>
</div> <!-- end of content left -->
<div id="content_right">
<div class="right_col_section_w650">
<div class="header_01">รายการสินค้า</div>
<?php include"connect.php";?>
<td>
<table width="100%" broder="0" cellspacing="4">
<?php
$hostNameDB = "localhost";
$userNameDB = "root";
$passWordDB = "root";
//$conn = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
$conn = mysql_connect($hostNameDB, $userNameDB, $passWordDB) or die ("Cannot connect to Server or connect db_cmpdurable Database");
mysql_query("SET NAMES utf8", $conn);
mysql_query("USE db_listmenu");
$page = (isset($_GET['page']))? intval($_GET['page']) : 1;
$limit_end = 3;
$limit_start = ($page-1)*$limit_end;
$send = "";
if(isset($_GET["id_cus"]) and $_GET["id_cus"] != ""){
$send = "id_cus=" . $_GET["id_cus"];
$condition= " WHERE cus_id = '" . $_GET["id_cus"] . "'";
}
$sql = "SELECT * FROM tbuser". $condition;
$query_id = mysql_query($sql . " LIMIT " . $limit_start. "," . $limit_end, $conn);
$count = mysql_num_rows($query_id);
$total = mysql_num_rows(mysql_query($sql, $conn));
if($total > 0){
while($rs = mysql_fetch_assoc($query_id)){
$id_cus = $rs[cus_id];
$code_cus = sprintf("%05d",$id_cus);
$fname_cus = $rs[cus_fname];
$lname_cus = $rs[cus_lname];
$msg = $rs[msg];
$tel_cus = $rs[cus_tel];
$email_cus = $rs[cus_email];
echo"<tr>
<td><center><?=$no?></center></td>
<td><?=$id_cus?></td>
<td><?=$fname_cus?></td>
<td><?=$lname_cus?></td>
<td><?=$msg?></td>
<td><?=$tel_cus?></td>
<td><?=$email_cus?></td>
</tr>
<?
$no++; 
}
?>";
}
echo "\n<div style=\"float:left;\">Page : " . page_navi($page, $limit_end, 3, $total, "current_page","other_page",$send) . " </div><div style=\"float:right;\">[" . ($limit_start+1) . "-" . ($limit_start+$count) . "] of <strong>" . $total . "</strong></div>";
}
?>
</div>
<div class="margin_bottom_20"> </div>
<div class="margin_bottom_20"> </div>
</div> <!-- end of right_col_section_w220 -->
</div> <!-- end of content right -->
<div class="cleaner"> </div>
</div> <!-- end of container -->
<!-- Free CSS Templates by www.TemplateMo.com -->
</div> <!-- end of container -->
</body>
</html>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-17 15:53:50 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 <? 
$no++;  
} 
?>"; น่าจะ error นะ 
} 
echo "\n<div style=\"float:left;\">Page : " . page_navi($page, $limit_end, 3, $total, "current_page","other_page",$send) . " </div><div style=\"float:right;\">[" . ($limit_start+1) . "-" . ($limit_start+$count) . "] of <strong>" . $total . "</strong></div>"; 
} 
?>                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-17 21:30:22 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 แล้วเราต้องแก้ยังไงหรอค่ะ ><                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-17 22:48:25 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 เธอก็เอา ?>"; น่าจะ error นะ ออกไปไง                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 05:43:33 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 โค้ดอันนี้มันคำนวณผิดอ่าค่ะ  แล้วเราจะทำยังไงให้มันแสดงหน้าละ 3 แถวละค่ะ 
 
ในฐานข้อมูลตารางนี้มีข้อมูล 7 ข้อมูลอ่าค่ะ  แต่โค้ดนี้มันออกมาทั้งหมดเลย คลิ๊กไปหน้าอื่นก็ออกมาเหมือนหน้าแรก  
 
แบบนี้อ่าค่ะ 
 
  
 
 
Code (PHP) 
<?php session_start();
	include('config.php');
	$sql = "select*from tbuser order by cus_id desc ";
	$result = mysql_db_query("$dbname","$sql");
	$no = 1; 	
?>
<html>
<head>
<title>แบ่งหน้า</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM tbuser ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 5;   // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
	$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
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;
}
$strSQL .=" order  by cus_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);
?>
<table border="1" align="center">
				<tr bgcolor="#678c0d">
					<td><center><b>ลำดับ</b></center></td>
					<td><center><b>เลขบัตรประชาชน</b></center></td>
					<td><center><b>ชื่อ</b></center></td>
					<td><center><b>นามสกุล</b></center></td>
					<td><center><b>ที่อยู่</b></center></td>
					<td><center><b>เบอร์โทร</b></center></td>
					<td><center><b>อีเมล์</b></center></td>
				</tr>
				<?php 
					while($rs=mysql_fetch_array($result)){
						$id_cus = $rs[cus_id];
						$code_cus = sprintf("%05d",$id_cus);
						$fname_cus = $rs[cus_fname];
						$lname_cus = $rs[cus_lname];
						$msg = $rs[msg];
						$tel_cus = $rs[cus_tel];
						$email_cus = $rs[cus_email];
						?>
				<tr>
					<td><center><?=$no?></center></td>
					<td><?=$id_cus?></td>
					<td><?=$fname_cus?></td>
					<td><?=$lname_cus?></td>
					<td><?=$msg?></td>
					<td><?=$tel_cus?></td>
					<td><?=$email_cus?></td>
					</tr>
					<?
					$no++;	
					}
				?>
			</table>
<br>
<center>รวม <?= $Num_Rows;?> รายการ: <?=$Num_Pages;?> หน้า :
<?
if($Prev_Page)
{
	echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
	if($i != $Page)
	{
		echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
	}
	else
	{
		echo "<b> $i </b>";
	}
}
if($Page!=$Num_Pages)
{
	echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysql_close($objConnect);
?></center>
</body>
</html>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 21:28:15 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 $objQuery  = mysql_query($strSQL); 
while($rs=mysql_fetch_array($result)){ 
 
ลองแก้เองดูนะ ทำตัวหนาให้เห็นแล้วว่าผิดตรงไหน                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 21:44:40 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ขอบคุณมากๆๆนะค่ะ  ได้แล้วค่ะ 
 
แต่ทำยังไงให้หน้า2 ลำดับเลขมันนับต่อจากหน้าแรกอ่ะค่ะ 
 
เพราะหน้า2 มันเริ่มนับหนึ่งใหม่                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 22:16:07 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
$no=$no+$Page_Start;
while($rs=mysql_fetch_array($result)){
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 22:23:51 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ตอนนี้ได้หมดแล้วนะค่ะ 
 
ขอบคุณพี่ PlaKriM นะค่ะที่คอยช่วยเหลือตลอดเลย 
 
พอดีหนูเพิ่งฝึกทำอ่าค่ะ ไม่มีพื้นฐานphpมาก่อนเลย 
 
ขอบคุณพี่ที่คอยแนะนำและ แก้ไขปัญหาให้ค่ะ                           
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 22:55:01 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ยินดีครับ                          
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 23:22:50 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 รบกวนอีกหน่อยนะค่ะ 
 
จาก No. 1  
 
 
เวลาเรากดดูข้อมูลหน้าอื่น มันจะเด้งออกมาอีกหน้าต่างอ่ะค่ะ 
 
อยากให้มันเปลี่ยนเพจนั้นเลย ทำไงค่ะ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 23:28:04 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ตกลงใช้โค๊ดตัวไหนครับ เอาโค๊ดที่ใช้มาแปะอีกรอบซิ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-18 23:48:12 | 
                        By :
                            PlaKriM | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 เอาคำถามใหม่ดีกว่าค่ะ 
 
จากโค้ดนี้ สินค้าจะแสดง แถวละชิ้นเรียงลงมา 3 ชิ้นแบบ 
 
[  ] 
 
[  ] 
 
[  ] 
 
 
แต่ถ้าเราอยากให้มันเรียงแถวละ 2 ชิ้น 3 แถวแบบนี้ต้องทำไงค่ะ 
 
[  ]     [  ] 
 
[  ]     [  ] 
 
[  ]     [  ] 
 
 
Code (PHP) 
<?php
require("auth.inc.php");
$sql="select * from product where type_id='$id_type_select'";
$id_type_select=$_GET[id_type];
?>
<!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=utf-8" />
<title>ร้านบีบุค ทู แฮนด์</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body onload="document.a.username.focus();">
<div id="templatemo_container">
	<div id="templatemo_header"></div> 
<!-- end of header -->
    
    <div id="templatemo_menu">
        <ul>
            <li><a href="index2.php" class="current">หน้าแรก</a></li>
			<li><a href="bbook2.php">รายการสินค้า</a></li>
            <li><a href="basket.php">ตะกร้าสินค้า</a></li>
            <li><a href="bbook6.php">ใบสั่งซื้อ</a></li>
		    <li><a href="bbook5.php">แจ้งการโอนเงิน</a></li>
            <li><a href="bbook6.php">กระบวนการสั่งซื้อ</a></li>
             <li><a href="bbook5.php" class="last">ติดต่อ</a></li>
        </ul>     	
    </div> <!-- end of menu -->
    
    <div id="templatemo_content">
        
        <div id="content_left">
        
         <div class="content_left_section">
            	<div class="content_left_section_title">ข้อมูลการเข้าระบบ</div>
				<div class="content_left_section_content2">
                     <Form action="login.php" method=post name=a>
<center>
<TABLE>
<tr><td>
<?php
require("auth.inc.php");
echo "<center>Welcome <b>" . $_SESSION['ses_user'] . "</b><br>"; 
echo " Login เข้ามาล่าสุดเมื่อ <b>" . $_SESSION['last_log'] . "</b></center>"; 
?>
</td></tr></TABLE></center>
</form>
<center><br><a href=updateform.php>แก้ไขข้อมูลส่วนตัว</a> <br>
            <a href=logoff.php>ออกจากระบบ</a></center><br>
                    <div class="cleaner"> </div>
                </div>	
                <div class="cleaner"> </div>
            	<div class="content_left_section_bottom"> </div>
            </div>
            
            <div class="margin_bottom_20"> </div>
        	<div class="content_left_section">
            <div class="content_left_section_title">ประเภทสินค้า</div>
				<div class="content_left_section_content">
                	<?php	include"connect.php";
				include"type_list.php";
		?>  
                </div>
	
            	<div class="content_left_section_bottom"> </div>
            </div>
            
            <div class="margin_bottom_20"> </div>
            
            <div class="content_left_section">
            	<div class="content_left_section_title">ตรวจสอบการจัดส่งสินค้า</div>
   	  <div class="content_left_section_content">
                        <a href="http://track.thailandpost.com/trackinternet/Default.aspx?lang=th"><img style="border:0;width:160px;height:40px" src="images/logopost.jpg" alt="logopost" width="120" height="35" vspace="8" border="0" /></a>
                    </div>                    
	                <div class="cleaner"> </div>
                    <div class="content_left_section_bottom"> </div>
            </div>
            
            <div class="margin_bottom_20"> </div>
            
            <div class="content_left_section_ad">
            	<img src="images/templatemo_ad.jpg" alt="image" />
            </div>
            
        </div> <!-- end of content left -->
        
		<div id="content_right">
        
            <div class="right_col_section_w650">
    
                <div class="header_01"><center>รายการสินค้า</center></div>
            
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM product ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 3;   // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
	$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
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;
}
$strSQL .=" order  by pro_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);
?>
  <?php	include"connect.php";?>
			<td>
			<table width="100%" broder="0" cellspacing="4">
			<?php
			while($rs=mysql_fetch_array($objQuery)){
				$id_pro=$rs[pro_id];
				$code=sprintf("%05d",$id_pro);
				$name_pro=$rs[pro_name];
				$detail_pro=$rs[pro_detail];
				$ref_id_type=$rs[type_id];
                $price_pro=$rs[pro_price];
			    $photo_pro=$rs[pro_photo];
				if($photo_pro==""){$photo_pro="temp.jpg";}
echo"<tr>
			<td width='20%' valign='top'> <img src='imgProduct/$photo_pro'></td>
            <td width='80%' valign='top'><br><br><br><b>รหัสสินค้า :</b> $code<br>
										 <b>ชื่อสินค้า :</b> $name_pro<br>
										 <b>ราคา :</b> $price_pro บาท<br><br>
					[<a href='product_view.php?id_pro=$id_pro'>แสดงรายละเอียด</a>]
					[<a href='basket_add.php?id_pro=$id_pro'>หยิบใส่ตะกร้า</a>]<br><br><br><br>
			</td>
		</tr>";
			}
?>
            
<center>รวม <?= $Num_Rows;?> รายการ: <?=$Num_Pages;?> หน้า :
<?
if($Prev_Page)
{
	echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
	if($i != $Page)
	{
		echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
	}
	else
	{
		echo "<b> $i </b>";
	}
}
if($Page!=$Num_Pages)
{
	echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysql_close($objConnect);
?></center>
           
          </div>
        <div class="margin_bottom_20"> </div>
                                                
                <div class="margin_bottom_20"> </div>
                
            </div> <!-- end of right_col_section_w220 -->
            
        </div> <!-- end of content right -->
        
        <div class="cleaner"> </div>
	</div> <!-- end of container -->
<!--  Free CSS Templates by www.TemplateMo.com  -->
    
</div> <!-- end of container -->
</body>
</html>
 
 
 
ขอบคุณล่วงหน้านะค่ะ ^^                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-02-19 01:15:11 | 
                        By :
                            nu44 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
      		  
	
     | 
   
 
                 |