air
air

Reputation: 6264

codeigniter getting data without foreach

I am trying to select data from two tables
and then send it back as array to function
and pass that data array to my view using codeigniter.

My array of values coming from database is like bellow, when I print_r it in view

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 
      ) 
 )

Actually its return two rows. If you notice the value of project_name in both rows are same

Now I want to print project_name value on top of row then I will repeat the rows with foreach.

How to get project_name value before foreach?

Upvotes: 0

Views: 2247

Answers (1)

Shoe
Shoe

Reputation: 76280

To print the project name you can do $array[0]->project_name.

Upvotes: 3

Related Questions