【问题标题】:how to display multiple views on different pages in codeigniter如何在codeigniter的不同页面上显示多个视图
【发布时间】:2013-01-24 23:36:15
【问题描述】:

我是 codeigniter 的新手。我想在不同的页面上显示多视图。我创建了一个页面,在该页面上创建了一个编辑按钮。我希望当我点击编辑按钮时,我会在另一个页面上进行重定向。我该怎么做?

这是我的代码:

class Edit extends CI_Controller
{
    function __construct()
    {
            parent::__construct();
    }
    function edit()
    {
        $this->load->helper('url');
        if($this->input->post('edit') == True)
        {
            redirect('edit');
        }
    }
}

【问题讨论】:

  • $this->load->view('edit_view');
  • 你能详细说明一下@AlphaMale
  • 请在此处阅读文档:ellislab.com/codeigniter/user-guide
  • @jayant.porwal 这取决于。你是在问如何加载视图???
  • @AlphaMale 我在问如何在另一个页面上加载视图。 . .当我点击编辑时,我想切换到另一个页面

标签: php javascript mysql codeigniter


【解决方案1】:

该按钮将在视图中,这意味着单击视图中的按钮应重定向到其他页面(视​​图):

在视图上使用锚点:

 <?php echo anchor('controller_name/function_name', 'acnchor_name'); ?>

 <?php echo anchor('Edit/edit', 'edit'); ?>

其中 edit 必须是函数和视图的名称。

现在点击它时会出现一个视图链接,它将重定向到编辑视图。

希望能帮到你!

【讨论】:

    【解决方案2】:

    查看 1:(您的链接所在的位置)

    <?php echo anchor('Edit/edit', 'Edit Value'); // Here Edit is your controller and edit is the function name. ?>
    

    在编辑控制器中修改如下:

    class Edit extends CI_Controller
    {
        function __construct()
        {
                parent::__construct();
        }
    
        function edit()
        {
            $this->load->helper('url');
            if($this->input->post('edit') == True)
            {
                //redirect('edit'); //Do not use this as this line will call the same function again.
                $this->load->view('edit_view'); // where edit_view.php is present in your views directory. 
            }
        }
    }
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-04
      • 1970-01-01
      • 2020-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 2018-12-10
      相关资源
      最近更新 更多