wayne173
发表于 2009-10-22 11:08:22
e .看完了。果然省事了不少。
kly521
发表于 2009-11-2 16:55:10
感谢Hex的翻译~!
richardhc
发表于 2010-1-13 15:18:59
谢谢啦`~~~
才开始看ci...
z445619791
发表于 2010-1-19 11:10:59
继续研究
:victory:
z445619791
发表于 2010-1-19 13:21:41
//load pagination class
$this->load->library('pagination'); //加载分页类
$config['base_url'] = base_url().'index.php/books/index/'; //配置要分页页面的 URL
$config['total_rows'] = $this->db->count_all('christian_books'); //计算出指定表的总行数并返回
$config['per_page'] = '5'; //每个页面中希望展示的项目数量
$config['full_tag_open'] = '<p>'; //使用标签包围分页链接
$config['full_tag_close'] = '</p>'; //使用标签包围分页链接
//其他都OK就是自定义分页不成功 不知道为什么
$config['first_link'] = 'First'; //分页的左边显示“第一页”链接的名字。
$config['last_link'] = 'Last'; //分页的右边显示“最后一页”链接的名字。
//$config 数组包含了配置参数。这些参数被 $this->pagination->initialize 方法传递
$this->pagination->initialize($config);
其他都OK就是自定义分页不成功 不知道为什么
Hex
发表于 2010-1-19 14:29:35
回复 65# z445619791
结果是没有修改还保持原来的英文??
z445619791
发表于 2010-1-20 10:27:59
回复 66# Hex
结果还是和原来一样就是没改变 之前如何现在也如何 重启也一样
Hex
发表于 2010-1-20 10:53:03
回复 67# z445619791
把所有控制器代码贴一下看看,这个看起来没问题呀。
z445619791
发表于 2010-1-20 12:33:12
回复 68# Hex
Books.php
<?php
class Books extends Controller {
function __construct() {
parent::Controller(); //使用parent调用了父类的构造函数
$this->load->helper('url'); //加载 URL 辅助函数,文件包含一些在处理 URL 中很有用的函数
$this->load->database(); //依据database.php的数据库配置载入并初始化数据库
}
function index() {
//load pagination class
$this->load->library('pagination'); //加载分页类
$config['base_url'] = base_url().'index.php/books/index/'; //配置要分页页面的 URL
$config['total_rows'] = $this->db->count_all('christian_books'); //计算出指定表的总行数并返回
$config['per_page'] = '5'; //每个页面中希望展示的项目数量
$config['full_tag_open'] = '<p>';//使用标签包围分页链接
$config['full_tag_close'] = '</p>';//使用标签包围分页链接
//其他都OK就是自定义分页不成功 不知道为什么
$config['first_link'] = 'First'; //分页的左边显示“第一页”链接的名字。
$config['last_link'] = 'Last';//分页的右边显示“最后一页”链接的名字。
//$config 数组包含了配置参数。这些参数被 $this->pagination->initialize 方法传递
$this->pagination->initialize($config);
//load the model and get results
$this->load->model('books_model'); //载入模板文件
//$this->uri->segment(n) 重新分割一个详细的URI分段。n 为你想要得到的段数。
$data['results'] = $this->books_model->get_books($config['per_page'],$this->uri->segment(3));
// load the HTML Table Class
$this->load->library('table'); //加载表格类
$this->table->set_heading('ID', 'Title', 'Author', 'Description'); //设置表格的表头
// load the view
$this->load->view('books_view', $data); //载入一个视图文件
}
}
?>
books_model.php
<?php
class books_model extends Model {
function __construct(){
parent::Model();
}
function get_books($num, $offset) {
$query = $this->db->get('christian_books', $num, $offset); //运行选择查询语句并且返回结果集获取一个表的全部数据第二和第三个参数允许你设置一个结果集每页纪录数(limit)和结果集的偏移(offset)
//SELECT * FROM christian_books LIMIT $offset, $num
return $query;
}
}
?>
book_view
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>CodeIgniter Pagination Tutorial</title>
</head>
<body>
<h1>Christian Books</h1>
<?php echo $this->table->generate($results); //包含生成的表格的字符串。?>
<?php echo $this->pagination->create_links(); //创建各页页码的链接 ?>
</body>
</html>
能不能把 让更多的朋友了解 CI 的任务条件降低点啊 呵呵
lcbat
发表于 2010-3-19 11:26:12
很强大的说呵呵
页:
1
2
3
4
5
6
[7]
8
9
10
11
12
13
14