avi*_*hse 5 html php parameters codeigniter hyperlink
有没有办法从控制器发送数据到视图.我正在做的是用户可以选择链接,根据链接用户点击,相应的数据传递给控制器,另一个视图从对应于该链接的控制器加载.但我不知道该怎么做.我在这里使用篝火是我的控制器代码: -
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();
}
}
Run Code Online (Sandbox Code Playgroud)
在我的模型部分: -
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;
}
Run Code Online (Sandbox Code Playgroud)
我的意见是: -
<?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
}
?>
Run Code Online (Sandbox Code Playgroud)
在我的full_post控制器函数中,我想要用户在链接中单击的参数click to see.帮助台是我的控制器名称.helpdesk_model是我的型号名称.而my_tickets是我的名字..
我正在使用隐藏字段的表单的帮助下执行此操作:-我稍微更改了我的视图页面,如下所示:-
for ($i=0; $i <$arraysize; $i++) {
echo "<p>".($i+1).". ".$title[$i]." | ".$category[$i]." | ".$priority[$i]." | ".$date[$i]." | ".$post_status[$i]."</p>";
echo form_open('/helpdesk/full_post');
echo form_hidden('path',$userfile_path[$i]);
echo form_submit('submit', 'click to see');
echo form_close();
}
Run Code Online (Sandbox Code Playgroud)
在控制器页面中我正在做:-
function full_post(){
Template::set('path',$this->input->post('path'));
Template::render();
}
Run Code Online (Sandbox Code Playgroud)
这是我需要的东西,这是好方法吗..?还有其他更好的想法吗?