如何将数据从Controller传递到CodeIgniter中的View?
控制器
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Hello extends CI_Controller {
public function index()
{
$data['hello']= "helloooo";
$this->load->view('hello_world');
}
}
答案 0 :(得分:1)
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Hello extends CI_Controller {
public function index()
{
$data['hello']= "helloooo";
$this->load->view('hello_world',$data);
}
}
在您的视图中
echo $hello;
答案 1 :(得分:0)
select employees.employee_name ,employers.employer_name
from employees
left join employers
on employees.employee_id = employees.employee_id
where employers.employer_name is NULL
在视图页面hello_world
中jQuery(document).ready(function($) {
$('.test1').click(function() {
var p = $(this);
var position = p.position();
console.log(position);
});
});
答案 2 :(得分:0)
在加载视图时将数据作为参数传递。
{{1}}