doubaran2438 2013-04-13 00:30
浏览 40
已采纳

如何在codeigniter中传递数组和变量

i want to pass an array and two variables to my view my array is passed in views successfully but the two variable is undefined.can anyone help me how to pass those values to view.i tried indexing,then the model doesn't work.

my controller

$Semister=$this->input->post('Semister');
    $Dept=$this->input->post('Dept');
    $this->load->model('Upload_Result_Model');
    $data['subjects']=$this->Upload_Result_Model->getAllSubjects($Semister,$Dept);
    $data['student']=$this->Upload_Result_Model->getAllStudent($Semister,$Dept);
    $this->load->view('Faculty/upload_mid_result',$data,$Dept,$Semister);

my view

<h3>Department: <?php echo $Dept;?></h3> //error Undefined variable: Dept
<h3>Semister: <?php echo $Semister;?></h3> ////error Undefined variable: Dept

can ayone help me fixing this problem.everything works fine except $dept and $Semister. Thanks i advance

  • 写回答

3条回答 默认 最新

  • donglun1020 2013-04-13 00:32
    关注

    Try this,

    $data['Semister'] =$this->input->post('Semister');
    $data['Dept']     =$this->input->post('Dept');
    $this->load->model('Upload_Result_Model');
    $data['subjects']=$this->Upload_Result_Model->getAllSubjects($data['Semister'],$data['Dept']);
    $data['student']=$this->Upload_Result_Model->getAllStudent($data['Semister'],$data['Dept']);
    $this->load->view('Faculty/upload_mid_result',$data);
    

    You can access all the variables directly in view like how you are accessing now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 FineReport文本日期格式转日期格式后查不出数据
  • ¥100 二维码被拦截如何处理
  • ¥15 怎么解决LogIn.vue中多出来的div
  • ¥15 优博讯dt50巴枪怎么提取镜像
  • ¥30 在CodBlock上用c++语言运行
  • ¥15 求C6748 IIC EEPROM程序固化烧写算法
  • ¥50 关于#php#的问题,请各位专家解答!
  • ¥15 python 3.8.0版本,安装官方库ibm_db遇到问题,提示找不到ibm_db模块。如何解决?
  • ¥15 TMUXHS4412如何防止静电,
  • ¥30 Metashape软件中如何将建模后的图像中的植被与庄稼点云删除
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部