Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > สร้าง Group 2 Group ใน ตาราง group ที่ 2 ไม่ยอม group ตามที่ได้กำหนดไว้



 

สร้าง Group 2 Group ใน ตาราง group ที่ 2 ไม่ยอม group ตามที่ได้กำหนดไว้

 



Topic : 103235

Guest




อยากให้ตารางมันออกมาเป็นแบบนี้
1

แต่พอทำแล้วตารางมันกลับออกมาเป็นแบบนี้อ่ะค่ะ Group ในคอลัมน์ที่ 2 ไม่ยอม Group ตามที่ต้องการ ออกมาแค่ group เดียว ต้องแก้โค๊ดยังไงดีค่ะ
2


โค๊ด

Code (PHP)
public function product() {
          error_reporting(0);
       $response = array();      
          $this->load->library("table_component_custom");
  $report_data = $this->report_query_model3->get_data_product($this->input->post(), $this->input->post("start_record"), $this->page_limit);
          if ($report_data != false) {
  $header = array("กลุ่ม","ประเภท","รหัส", "ราคา", "จำนวน");
            $align = array( "center"  ,"center",  "left",       "right",  "right");
            $width = array(  "150",   "200",   "400",        "150",       "150");
    $row_count = $this->report_pagging_model2->get_count_product($this->input->post());
    $paging_data = $this->pager_model->get_paging_data($row_count, $this->input->post("txtreportcode"), $this->page_limit);

            $this->table_component->set_alignment($align);
            $this->table_component->set_column_width($width);
            $this->table_component_custom->set_table_header($header);
            $this->table_component->set_table_content($report_data);

             $group_dataz = group_array($report_data, "Protype");
            $group_datay = group_array($report_data, "ProGroup");
           
       
            #sum total
            $Sum_sum_ProCount = 0; 
            $Sum_sum_ProPrice = 0; 
            
                     
             foreach ($group_datay as $index => $row) {
                #row total
            $sum_ProCount = 0; 
            $sum_ProPrice = 0; 
            
             $current_num_row = count($row) + 1;
                $rowspan = '  rowspan="' . $current_num_row . '"  ';
                $Protype= $row[0]["Protype"];
                $ProGroup = $row[0]["ProGroup"]; 
                           
                
                 foreach ($row as $step => $value) {
                     $sum_ProCount += str_replace(",", "", $value["ProCount"]);
                    $sum_sum_ProPrice+= str_replace(",", "", $value["ProPrice"]);
                    if ($step == 0) {

                        $this->table_component_custom->append_content(
                                
                 '<tr  class="content-font">
                                                    
                                                    <td  height="25"  bgcolor="#ffffff"  align="center" ' . $rowspan . '> ' .$ProGroup . '</td>                                                
                                            <td  height="25"  bgcolor="#ffffff"  align="center" ' . $rowspan . '>' . $Protype . '</td> 
                                                    <td  height="25" bgcolor="#ffffff"  align="left">&nbsp;' . $value["ProID"] . '</td>                                              
                                                    <td  height="25" bgcolor="#ffffff" align="right" >&nbsp;' . number_format(str_replace(",", "", $value["ProCount"]), 0) . '&nbsp;</td>                                            
                                                    <td  height="25" bgcolor="#ffffff"  align="right" >&nbsp;' . number_format(str_replace(",", "", $value["ProPrice"]), 2) . '&nbsp;</td>

                                            </tr>'                              
                        );
              } else {
                        $this->table_component_custom->append_content(
                                '<tr  class="content-font"> 
                                    
                                                    <td  height="25" bgcolor="#ffffff"  align="left">&nbsp;' . $value["ProID"] . '</td>                                                   
                                                    <td  height="25" bgcolor="#ffffff" align="right" >&nbsp;' . number_format(str_replace(",", "", $value["ProCount"]), 0) . ' &nbsp;</td>
                                                    <td  height="25" bgcolor="#ffffff"  align="right" >&nbsp;' . number_format(str_replace(",", "", $value["ProCount"]), 2) . '&nbsp;</td>                                                   
                                             </tr>'
                        );
                    }
                 
                 $rowspan = "";             
                 }
                                                                  
                 $Sum_sum_ProPrice += $sum_ProPrice;
                $Sum_sum_ProCount += $sum_ProCount;
                
                 $this->table_component_custom->append_content(
                       
                        '<tr  class="content-font">
                                                   
                                                    <td  height="25" bgcolor="#eeeeee"  align="center" colspan="1">รวมประเภท ' . $Protype . '</b></td>
                                                    <td height="25" bgcolor="#ffffff"  align="right"><b>' . number_format($sum_ProCount, 0) . '</b>&nbsp;</td>
                                                    <td height="25" bgcolor="#ffffff"  align="right"><b>' . number_format($sum_DiscountPrice, 2) . '</b>&nbsp;</td>                                                   
                       </tr>'
                        
                );
                $this->table_component_custom->append_content(
                        '<tr  class="content-font">
                                               
                                                    <td  height="25" bgcolor="#eeeeee"  align="center" colspan="3">&nbsp;<b>รวมกลุ่ม ' . $ProGroup . '</b></td>                       
                                                    <td height="25" bgcolor="#ffffff"  align="right"><b>' . number_format($sum_ProCount, 0) . '</b>&nbsp;</td>
                                                    <td height="25" bgcolor="#ffffff"  align="right"><b>' . number_format($sum_ProPrice, 2) . '</b>&nbsp;</td>                                                   
                       </tr>'
                        
                );
           
                $Sum_sum_ProCount += $sum_ProCount;
                $Sum_sum_ProPrice += $sum_ProPrice;
            }           
         foreach ( $report_data as $val){ 
           $ProCount=$ProCount+$val["ProCount"] ; 
           $ProPrice=$ProPrice+$val["ProPrice"] ; 
         }
                $this->table_component_custom->append_content(
                    '<tr  class="content-font">
                                             <td height="25" bgcolor="#eeeeee"  align="center" colspan="3">&nbsp;<b>รวมทั้งหมด</b></td>                                                   
                                                   <td height="25"  bgcolor="#eeeeee"  align="center"><b>' . number_format($ProCount, 0) . '</b>&nbsp;</td>
                                                  <td height="25"  bgcolor="#eeeeee"  align="right"><b>' . number_format($ProPrice, 2) . '</b>&nbsp;</td>
                                                    
                                                        
                  </tr>'
              );
           }
//number_format($avg_lf_all,2 ) . ":" . 
            $response['content'] = $this->table_component_custom->get_table();
            //$response['pager'] = $this->load->view("report/pager_view", $paging_data, true);

            echo encode_ajax_data($response);
        } else {
            $response['content'] = "ไม่พบข้อมูลในช่วงเวลาดังกล่าว";
            $response['pager'] = "";
            echo encode_ajax_data($response);
        }
    }




Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-12-02 09:44:17 By : RKkh View : 762 Reply : 1
 

 

No. 1



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ไม่มีโค้ดนะครับ แต่จะบอกมาถูกทางแล้วครับ ลองเช็คค่า การบวก ของแต่และช่วงดีดี คงมีผิดพลาด....เล็กน้อย






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-12-02 19:02:11 By : apisitp
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สร้าง Group 2 Group ใน ตาราง group ที่ 2 ไม่ยอม group ตามที่ได้กำหนดไว้
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่