  | 
              
	              
	                
  
    
	 
        รบกวนเรืองตารางอีกรอบนะคับ ม่รู้ว่าที่ผมต้องการนี่มันทำได้รึป่าวคับเพราะมีตัวอ้างอิงเเค่ตัวเดียวคือ isbn ยังไงรบกวนอีกรอบนะคับ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
               <? 
require_once("../include/connect_db.php");?> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"> 
<table width="371" border="1" cellpadding="1" cellspacing="1"> 
<tr> 
<td width="66">รหัสสินค้า</td> 
<td width="144">ชื่อสินค้า</td> 
<td width="53">จำนวน</td> 
<td width="41">ราคา</td> 
<td width="39">รวม</td> 
</tr> 
<? 
$conn=connect_db("project"); 
if(!$conn) 
echo "เกิดความผิดพลาดไม่สามารถติดต่อกับฐานข้อมูลได้"; 
$sql1 = "select * from order_items o , product p where orderid='$orderid'"; 
$result1= mysql_db_query(project,$sql1); 
while($row1=mysql_fetch_array($result1)) 
{ 
$pname=$row1[title]; 
$orderid=$row1[orderid]; 
$item_pice=$row1[item_pice ]; 
$quantity=$row1[quantity]; 
$price=$row1[quantity]*$row1[item_pice]; 
$total+=$price; 
echo " <tr> 
<td>$orderid</td> 
<td>$pname</td> 
<td>$quantity</td> 
<td>$item_pice</td> 
<td>$price </td> 
</tr>"; 
} 
 
?> 
</table><br> <? echo "จำนวนเงินทั้งหมด $total" ?> <br>  
 
กระทู้เก่าลองเเล้วมันไม่ได้อะคับ 
คือผมต้องการเชื่อมตารางสองตารางเข้าด้วยกันคือที่เชื่อมนี่เพราะข้อมูลชื่อมันไม่มีในตาราง order_items เเละตารางorder_items ประกอบด้วย orderid,quantity,$item_pice,isbn หรือรหัสสินค้า เเล้วผมต้องการเอา isbnไปหาชื่อของสินค้าจากตาราง product ซึ่งประกอบด้วย isbn ,author ,title หรือชื่อสินค้า ,price ,description picture,publisher,time ,page ,catid  
 
 
ไม่รู้ว่าที่ผมต้องการนี่มันทำได้รึป่าวคับเพราะมีตัวอ้างอิงเเค่ตัวเดียวคือ isbn ยังไงรบกวนอีกรอบนะคับ 
 
  Tag : - - - -              
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          27 ก.พ. 2550  09:05:35 | 
                      By :
                          ชิดชัย | 
                      View :
                          1600 | 
                      Reply :
                          3 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                $sql1 = "select * from order_items o , product p where orderid='$orderid'"; 
$result1= mysql_db_query(project,$sql1); 
 
ลองตรวจสอบ 2 บรรทัดนี้ดูนะครับ ผมว่ามันทะแม่งๆ ไปหน่อย 
 
ลองแบบนี้ดู 
 
$sql1 = "select * from order_items  , product  where (orderid='$orderid') AND (order_items.isbn=product.isbn)"; 
 
 
ลองดูนะครับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            27 ก.พ. 2550  10:23:34 | 
                        By :
                            ninja_noy | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                ใช้ได้เเล้วคับ ขอบคุณคุณ ninja_noy มากๆคับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            27 ก.พ. 2550  12:55:26 | 
                        By :
                            ชิดชัย | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                ครับผม ยินดีครับ                          
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            27 ก.พ. 2550  15:27:40 | 
                        By :
                            ninja_noy | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |