コントローラからビューにデータを送信する方法はありますか?私がやっていることは、ユーザーにはリンクのオプションがあり、リンクに従ってユーザーがクリックすると、対応するデータがコントローラーに渡され、そのリンクに対応するコントローラーから別のビューが読み込まれます。しかし、私はそれを行う方法がわかりません。私はここで焚き火を使用しています私のコントローラーコードです:-
function my_tickets() {
$username = $this->auth->username();
$this->load->model('helpdesk_model');
$result_set = $this->helpdesk_model->my_tickets($username);
foreach($result_set->result() as $data ) {
$title[] = $data->title;
$category[]=$data->category;
$priority[]=$data->priority;
$date[]=$data->date;
$post_status[]=$data->post_status;
$userfile_path[] = $data->userfile_path;
}
$arraysize=count($title);
Template::set('arraysize',$arraysize);
Template::set('title',$title);
Template::set('category',$category);
Template::set('priority',$priority);
Template::set('date',$date);
Template::set('post_status',$post_status);
Template::set('username',$this->auth->username());
Template::set('userfile_path',$userfile_path);
Template::render();
}
function full_post(){
Template::render();
}
}
私のモデル部分では:-
function my_tickets($username){
$this->db->select('title,userfile_path,category,priority,date,post_status');
$this->db->where('username',$username);
$result = $this->db->get('tbl_tickets');
return $result;
}
私の見解は:-
<?php
$arraysize =Template::get('arraysize');
$title[] = Template::get('title');
$category[]=Template::set('category');
$priority[]=Template::set('priority');
$date[]=Template::set('date');
$post_status[]=Template::set('post_status');
$username = Template::set('username');
$userfile_path = Template::set('userfile_path');
?>
<h3>Total Number Of posts : <?php echo $arraysize; ?> </h3>
<h2>Your Posts</h2>
<?php echo "serail. title | category | priority | date of starting post | post status "; ?>
<?php
for ($i=0; $i <$arraysize; $i++) {
?>
<p> <?php echo ($i+1).". ".$title[$i]." | ".$category[$i]." | ".$priority[$i]." | ".$date[$i]." | ".$post_status[$i];
echo "<a href=\"/helpdesk/full_post\">Click to see </a>";
?>
</p>
<?php
}
?>
私のfull_postコントローラー関数では、ユーザーがリンクをクリックするパラメーターが必要ですclick to see
。ヘルプデスクは私のコントローラー名です。helpdesk_modelは私のモデル名です。my_ticketsは私のビュー名です。