Welcome Guest, Not a member yet? Register   Sign In
push new array keys and values into simple array_slice
#1

[eluser]Ngulo[/eluser]
hi all guys , i'm trying to push inside my array some new value the script is simple:

Controller.php:

Code:
foreach($populateOrders as $row ){

                $id = $row->id;
                $newvalue =  "asd";
                $this->order_bills->populateById($id);
                $ordersList = array(
                'id'=>$row->id,
                'id_user'=>$row->id_user,
                'firstname'=>$row->firstname,
                'lastname'=>$row->lastname,
                'status'=>$row->status,
                'delivery_type'=>$row->delivery_type,
                'payment_type'=>$row->payment_type,
                'total'=>$row->total,
                'registration_datetime'=>$row->registration_datetime,
                'pdf'=>$row->pdf,
                'newvalue'=>$newvalue
                );
            }
            $view['orderList'] = array('list'=>array_slice($ordersList,$offset,$per_page));
            
        $this->load->view('admin/orders/orders_view',$view);

View.php
Code:
<?php foreach($orderList['list'] as $row){?>
                      
      <tr class="tr-right-options" id="tr-fade-out-&lt;?php echo $row->id ?&gt;">
      <td>&lt;?php echo $row->id ?&gt;</td>
                          
      <td class="order-firstname"><strong>&lt;?php echo $row->firstname ?&gt;</strong></td>
                            <td class="order-lastname"><strong>&lt;?php echo $row->lastname ?&gt;</strong></td>
                          &lt;!--  <td class="order-email"><strong>&lt;?php //echo $row->email ?&gt;</strong></td>--&gt;
                            <td>&lt;?php echo $row->status ?&gt;</td>
                            <td>&lt;?php echo $row->delivery_type ?&gt;</td>

etc etc........

so if i try to push inside controller $populateOrders array newvalue then in my view i receive error message (Message: Trying to get property of non-object) how can i solve this problem?

p.s: $populateOrders is generated by model and it is simply result array from $query->result();
#2

[eluser]cahva[/eluser]
Its an array so treat it like its an array. For example:
Code:
echo $row->firstname;

// Should be
echo $row['firstname'];
#3

[eluser]Ngulo[/eluser]
right man!! thanks Tongue




Theme © iAndrew 2016 - Forum software by © MyBB