0

我正在尝试从两个表中选择数据
,然后将其作为数组发送回函数
并使用 codeigniter 将该数据数组传递给我的视图。

当我print_r在视图中时,来自数据库的值数组如下所示

Array 
( 
     [0] => stdClass Object 
     ( 
         [task] => Receiving Building Permit 
         [task_status] => 0 
         [date_duration] => 25.08.08 (1 day) 
         [gallery] => 1 
         [download] => 1 
         [project_name] => Investment and Development 
     ) 
     [1] => stdClass Object 
     ( 
         [task] => Back Filling 
         [task_status] => 1 
         [date_duration] => 16.11.08 - 21.11.08 (7 days) 
         [gallery] => 1 
         [download] => 1 
         [project_name] => 
         Investment and Development 
      ) 
 )

实际上它返回两行。如果您注意到两行中 project_name 的值相同

现在我想project_name在行的顶部打印值,然后我将使用 foreach 重复这些行。

如何project_name在foreach之前获得价值?

4

1 回答 1

3

要打印项目名称,您可以这样做$array[0]->project_name

于 2013-01-26T14:16:15.317 回答