2013-01-02 60 views
0

我有一些數據的html表,並且該表中的一行包含該行中有關條目描述的所有歷史記錄(歷史數據位於與主表數據不同的數據庫表中)。從多維數組中獲取值到一個表中的行PHP

GROUP_CONCAT(DISTINCT est.id, '|', est.date_estimate ,'|', est.description_estimate SEPARATOR '|') as description_estimate_history 

與此數據庫查詢我得到所有與主記錄相關的條目。

$raw_data = explode("|", $this->reg['rows'][$id]['description_estimate_history']); 
$group_data = array_chunk($raw_data, 3); 

$this->reg['rows'][$id]['description_joined'] = print_r($group_data); 




    Array 
    (
     [0] => Array 
      (
       [0] => 105925 
       [1] => 2013-02-28 02:14:33 
       [2] => some text 
      ) 

     [1] => Array 
      (
       [0] => 105958 
       [1] => 2013-02-28 02:14:33 
       [2] => some text 
      ) 

    ) 
------------------- // other row 
    Array 
    (
     [0] => Array 
      (
       [0] => 
      ) 
    ) 
----------------- // another row 
    Array 
    (
     [0] => Array 
      (
       [0] => 
      ) 

    ) 
--------------- //yet another row 
    Array 
    (
     [0] => Array 
      (
       [0] => 105932 
       [1] => 2012-12-31 00:00:00 
       [2] => some text 
      ) 

     [1] => Array 
      (
       [0] => 105945 
       [1] => 2012-12-31 00:00:00 
       [2] => some text 
      ) 

    ) 

我無法弄清楚如何打印此數據爲表中的行狀date - text([0]條目號)當一個行可以有多個記錄

回答

0

試試這個片斷更好地瞭解上你的結果排列

foreach($group_data as $dataArray){ // looping through rows 
    foreach($dataArray as $array){ // looping through records  
     foreach($array as $value){ // looping through fields 
      print $value."<br />"; 
     } 
    } 
}