有什么方法可以将数据从控制器发送到视图。我正在做的是用户可以选择链接,并根据链接用户点击相应的数据传递给控制器,并从与该链接对应的控制器加载另一个视图。但我不知道该怎么做。我在这里使用篝火是我的控制器代码:-
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 是我的控制器名称。helpdesk_model 是我的模型名称。my_tickets 是我的视图名称..