gpt4 book ai didi

php - 如何在 codeigniter 中的不同页面上显示多个 View

转载 作者:可可西里 更新时间:2023-11-01 07:37:32 25 4
gpt4 key购买 nike

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

这是我的代码:

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

最佳答案

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

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

然后在编辑 Controller 中将其修改为:

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.
}
}
}

希望这对您有所帮助。

关于php - 如何在 codeigniter 中的不同页面上显示多个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14785523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com