Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have problem when i transfer value from view to controller. I don't get the value Here's my method

Manifest.php

<?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-2 m-3 btn-cus" href="<?php  echo base_url('PortClient/view_voyage/');?>">
  <h3>Voyage - <?=$voyage->voyage_number?></h3> 
  <small>Schedule - <?=$voyage->expected_arrival?> </small>
  </a>
<?php }  ?>

I want to get the value of voyage_id(Code above) in manifest.php(view page) and transfer it to controller. Here's my controller

PortClient.php

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();
    // your code here
    $this->load->view("port/client/sub_manifest/sub_manifest_1", $data);
}

and i will call it using $this->session->userdata() but it doesnt transfer.

What should I do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
259 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to either use a form and access the value on form submit. OR you can use AJAX to post the value and access it like: $this->input->post("voyage_id") instead of using the session


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...