  | 
              
	              
	                
  
    
	 
        รบกวนหน่อยครับ คือติดปัญหาเกี่ยวกับการค้นหารายการสั่งซื้อ โดยค้นหาจากชื่อลูกค้าครับ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                จาก code มันขึ้น error  mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in  on line 62 ซึ่งลองเเก้ไขดูเเล้วยังไม่ได้ครับ ผมขอคำเเนะนำเพิ่มเติมหน่อยครับ 
 
 
 
Code (PHP) 
<?php
session_start();
require_once'../../connect.php';
$row = 10; 
$page = 1;
if (isset($_GET['page']) && (int) $_GET['page'] > 0) {
    $page = (int) $_GET['page']; 
}
$query_mycart = "SELECT ordera.order_id, ordera.cus_name, order_detaila.order_total,  ordera.order_state ,ordera.payment_options , ordera.order_date, COUNT(order_detaila.order_id) as coid , "
        . "SUM(order_detaila.order_total) as coidd FROM ordera,order_detaila WHERE ordera.order_id=order_detaila.order_id "
        . "GROUP BY ordera.order_id ORDER BY ordera.order_id DESC ";
$mycart = mysqli_query($con, $query_mycart) or die(mysqli_error());
$totalRows_mycart = mysqli_num_rows($mycart); // ตรวจสอบตรงนี้ด้วย
$total_page = ceil($totalRows_mycart / $row); // จากนั้นก็มาหาจำนวนหน้า ceil เป็น function ที่ไว้สำหรับการปัดเศษ
if ($page >= $total_page) {
    $page = $total_page;
}
$start = ($page - 1) * $row;
if ($_GET["Search_order"] != "") {
    $query_mycart .= " where cus_name like '%" . $_GET["Search_order"] . "%'";
}
$query_mycart .= " order by cus_name Limit  $start,$row  ";
$prd = mysqli_query($con, $query_mycart);
?>
<h3 align="center"> รายการสั่งซื้อใหม่ </h3> 
<br>
<form class="form-inline my-2 my-lg-0">
    <input name="order_id" value="<?php echo $_GET["order_id"]; ?>" type="hidden">
    <input name="Search_order" id="Search_order" class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
    <button class="btn btn-outline-success my-2 my-sm-0 text-light border-light" type="submit">Search</button>
</form>
<table id="example" class="table"  border="1" align="center" bordercolor='#DCDCDC'>
    <thead bgcolor='#ADD8E6' align="center" >
        <tr>
            <th>รหัสสั่งซื้อ</th>
            <th>ลูกค้า</th>
            <th>จำนวนรายการ</th>
            <th>ราคารวม</th>
            <th>สถานะ</th>
            <th>วันที่ทำรายการ</th>
            <th>รูปแบบการชะระเงิน</th>
            <th>ยกเลิกรายการสั่งซื้อ</th>
        </tr>
    </thead>
    <?php
    if ($totalRows_mycart > 0) {
        while ($row_mycart = mysqli_fetch_array($prd)) {
            ?>
            <tbody align="center" bgcolor='#F0FFFF'>
                <tr>
                    <td>
                        <a href="detail_order_afer_cartdone.php?order_id=<?php echo $row_mycart['order_id']; ?>&act=show-order"  >  <!--target="_blank"-->
                            <?php echo $row_mycart['order_id']; ?>  
                        </a>
                    </td>
                    <td>
                        <?php echo $row_mycart['cus_name']; ?>
                    </td>
                    <td align="center">
                        <?php echo $row_mycart['coid']; ?>
                    </td>
 
 
  Tag : PHP, HTML5, JavaScript, Ajax, jQuery               
                        | 
           
          
            
		
  ประวัติการแก้ไข 2019-03-22 17:11:23	
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2019-03-22 17:11:00 | 
                      By :
                          worapong39 | 
                      View :
                          661 | 
                      Reply :
                          2 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
$prd = $con->query($query_mycart) or die( $query_mycart . '<br>'.$con->error);
if( $prd->num_rows<1){
  die('Data Empty <br>'. $query_mycart);  
}
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2019-03-23 08:33:36 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   ตอบความคิดเห็นที่ : 1 เขียนโดย : Chaidhanan เมื่อวันที่ 2019-03-23 08:33:36 
รายละเอียดของการตอบ ::
  ขึ้นเเบบนี้ครับ
 
SELECT ordera.order_id, ordera.cus_id, order_detaila.order_total, ordera.order_state ,ordera.payment_options , ordera.order_date, COUNT(order_detaila.order_id) as coid , SUM(order_detaila.order_total) as coidd FROM ordera,order_detaila WHERE ordera.order_id=order_detaila.order_id AND ordera.order_state=1 GROUP BY ordera.order_id ORDER BY ordera.order_id DESC where cus_name like '%sa%' Limit 0,10  
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where cus_name like '%sa%' Limit 0,10' at line 1
                         
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2019-03-23 13:20:42 | 
                        By :
                            worapong39 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |