gpt4 book ai didi

php - 如何从 codeigniter 调用两个或多个表并发送或加载以查看

转载 作者:搜寻专家 更新时间:2023-10-30 20:51:08 25 4
gpt4 key购买 nike

我在调用表时遇到问题,我得到错误,如何调用表并加载或发送到 View ?

这是代码:

if($page == 'index') {
$this->loggedIn();
} else if($page == 'register') {
$this->loggedRegisterIn();
}
else {
$this->notLoggedIn();

$this->load->library('session');

$this->load->model('model_users');

$data['userData'] = $this->model_users->fetchUserData($this->session->userdata('user_id'));
$data2['userData2'] = $this->model_users->fetchUserData($this->session->userdata('user_id'));
}

$this->load->view($page, $data, $data2);

这是错误信息:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: userData2

Filename: views/dashboard.php

Line Number: 179

Backtrace:

File: C:\xampp\htdocs\cobaan\e-magang\application\views\dashboard.php Line: 179 Function: _error_handler

File: C:\xampp\htdocs\cobaan\e-magang\application\controllers\Pages.php Line: 32 Function: view

File: C:\xampp\htdocs\cobaan\e-magang\index.php Line: 315 Function: require_once

最佳答案

这应该是(错误)

  $data['userData'] = $this->model_users->fetchUserData($this->session->userdata('user_id'));            
$data2['userData2'] = $this->model_users->fetchUserData($this->session->userdata('user_id'));
}

$this->load->view($page, $data, $data2);

像这样(正确)

  $data['userData'] = $this->model_users->fetchUserData($this->session->userdata('user_id'));            
$data['userData2'] = $this->model_users->fetchUserData($this->session->userdata('user_id'));
}

$this->load->view($page, $data); # pass only one array with different array pointer

所以在视野中

如果 foreach

foreach($userData as $item)
{

}

foreach($userData2 as $item)
{

}

如果 print_r

print_r($userData);
print_r($userData2);

关于php - 如何从 codeigniter 调用两个或多个表并发送或加载以查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42929762/

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