0

我有一些数据的 html 表,该表中的一行包含有关该行中条目描述的所有历史记录(历史记录数据位于单独的数据库表中,而不是主表数据)。

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] 是条目 ID)

4

1 回答 1

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 />";
       }
    }
}
于 2013-01-02T10:20:53.173 回答