【问题标题】:How to use routing in CodeIgniter如何在 CodeIgniter 中使用路由
【发布时间】:2015-04-24 11:42:16
【问题描述】:

如何在 CodeIgniter 中使用路由?我试过但没有结果。这是我的看法:

<a href="/survey/index.php/index/student_surveys/1/" class='btn btn-success'>  1 </a>
<a href='/survey/index.php/index/student_surveys/2/'class='btn btn-success'>  2 </a>
<a href='/survey/index.php/index/student_surveys/3/'class='btn btn-success'>  3 </a>

我试过这个:

$route['survey/index.php/index/student_surveys/1/'] = 'index/student_surveys/1/';
$route['survey/index.php/index/student_surveys/2/'] = 'index/student_surveys/1/';

但是当我将链接更改为测试时,它并没有改变。它仅适用于我的链接而不适用于路由。我的控制器是:

 public function student_surveys() {
$this->form_validation->set_rules('teacher', 'Teacher', 'required');
        $this->form_validation->set_rules('subject', 'Subject', 'required|callback_subject'); 
        if ($this->form_validation->run()==FALSE)
        {
            $this->student_surveys_show();
        } 
        else 
        {
$this->user_model->add_teacher_subject();
 redirect('/index/survey_show/' . $survey_id);
            }               
            
        }

    

【问题讨论】:

  • 你试过了吗,$this-&gt;load-&gt;view('survey_show',$survey_id,TRUE);
  • 我想使用路由。 :)

标签: codeigniter routing


【解决方案1】:

试试这个

$route['confirm_registration/(:any)']=  "login/confirm_registration/$1";

【讨论】:

  • 是的,但是我有 3 个链接,它应该重定向到“login/confirm_registration/$1”; if $route['confirm_registration/1'], "login/confirm_registration/$2";如果'confirm_registration/2'
  • 不,你不需要 3 美元或 4 美元,加 1 美元就可以了
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-09
相关资源
最近更新 更多