Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter从视图向控制器传递多个参数?_Php_Codeigniter - Fatal编程技术网

Php Codeigniter从视图向控制器传递多个参数?

Php Codeigniter从视图向控制器传递多个参数?,php,codeigniter,Php,Codeigniter,我有一个系统,可以输出许多图像,旁边有一个链接,可以将它们设置为专辑封面 我有多个相册,在我的数据库中有一个名为“is_feature”的字段,如果图像是封面,则该字段设置为1,如果图像不是封面,则设置为0 我不知道选择图像的最佳方式,我最初输出如下内容 <a href="/admin/set_photo/'.$image_id.'" title="Set this photo as the feature photo">Set</a> (image_id显然是图像

我有一个系统,可以输出许多图像,旁边有一个链接,可以将它们设置为专辑封面

我有多个相册,在我的数据库中有一个名为“is_feature”的字段,如果图像是封面,则该字段设置为1,如果图像不是封面,则设置为0

我不知道选择图像的最佳方式,我最初输出如下内容

<a href="/admin/set_photo/'.$image_id.'" title="Set this photo as the feature photo">Set</a>

(image_id显然是图像id),此函数将调用模型并将所有其他照片“is_feature”字段设置为0,而此照片“is_feature”设置为1

问题是它正在删除所有其他相册功能。我几乎需要传递到A链接中的变量,第一个是图像的id,第二个是相册的id,然后我的模型函数只能将“is_feature”设置为0,其中相册的id=传递的相册的id


有没有像这样传递两个变量?还是我的做法完全错了?

呃什么?你需要什么都可以通过

$data = array(
               'title' => 'My Title',
               'heading' => 'My Heading',
               'message' => 'My Message'
          );

$this->load->view('blogview', $data);

您可以将URL中的值设置为查询参数


您可以在控制器中检索

$image\u id=$this->input->get('var1');
$image_size=$this->input->get('var2');

根据数据类型作为字符串或数组,有3种传递数据的方式(根据您的要求,您可以使用下面介绍的任何一种方式):

通过视图 通过控制器 通过会话
不,我知道可以通过数组将信息从控制器传递到视图,我想做的是使用链接将多个参数从视图传递到控制器。对不起,我的问题措辞有点糟糕。问题是将参数从视图传递到控制器,而不是从控制器传递到视图。是的,基本上就是这样!只有我没有使用查询字符串。我不知道你可以通过url传递多个参数,我是一个codeigniter新手,从文档中我认为它仅限于一个参数(ie),谢谢你为我指明了正确的方向,非常感谢。
  //For data you collected through POST method from FORM, collect them as array
        $data=array(
            'employee_name' => $this->input->post('emp_name'),
            'employee_email' => $this->input->post('emp_email'),
            'employee_password' => $this->input->post('emp_password')
             );

$this->load-> view(''mynextpage", $data)
redirect('controller_name/index'.$valueofcustomer);
OR
redirect(base_url()."controller_name/index/".$valueofcustomer);



//then in your 'view', you can access value of customer like this:
$v_o_c = $this->uri->segment(3); 
echo "your value is " .$v_o_c;
$data = array(
                'user_name' => $user_name,
                'is_logged_in' => true
            );

$this->session->set_userdata($data); //set the session
redirect('another_controller/index'); 

//then access those in another_controller like this:
$in = $this->session->set_userdata('$data');

Note: Session data will available only for redirect and lost on next page request