当我转移到另一个页面获取数据时(PHP错误消息:试图获取非对象的属性)

I want to transfer data in another controller and show it on another page but it shows "Message: Trying to get property of non-object"

Here's my code

manifest.php(viewpage) - Wherein i want to get the value of voyage_id

    <?php foreach($voyage_info as $voyage) {  ?>

<input type="hidden" name="voyage_id" value="<?=$voyage->voyage_id?>">
                                                 <a class="btn btn-primary primary-bg btn-lg  col-md-4 m-2 btn-cus" href="<?php  echo base_url('PortClient/view_voyage/');?>">
 <h3>Voyage - <?=$voyage->voyage_number?></h3> 
 <small>Schedule - <?=$voyage->expected_arrival?> </small>
  </a>

  <?

php }  ?>

controller(getting the value of voyage_id)

public function view_voyage() {
    $this->Auth->authCheck();
    $data = $this->template();
    $voyage_id = $this->session->userdata('voyage_id');

    $data['view_cargo'] = $this->PortManifestModel->view_voyage($voyage_id)->result_array();


    // your code here

    $this->load->view("port/client/sub_manifest/sub_manifest_1", $data);
}

View page(Wherein i want to show the data)

    <div class=" col-md-2">


  <label>Container Number: <?=$view_cargo->container_id?></label>


   </div>

but it shows A PHP Error was encountered Severity: Notice

Message: Trying to get property of non-object

Filename: sub_manifest/sub_manifest_1.php

Line Number: 37

Line 37 is Container Number: container_id?>

what do i need to do?

1) You're using result_array() in your controller although you only want one result; use row_array() instead.

2) $view_cargo is not an object, it's an array, so do:

<label>Container Number: <?=$view_cargo['container_id']?></label>