qeephp内容分页
为什么80%的码农都做不了架构师?>>>
当列出查找的内容有很多条的时候我们可以将数据进行分页显示。
user表的结构如图:
现在要将用户以列表的形式显示,显然不可能将查询结果显示在一页当中,此时要将结果分页显示,首先将分页控件page.php复制到项目的control文件中,然后我们可以在控制器中输入如下代码:
function actionCusList(){$cus_info = User::find();//获取当前是第几页$page = intval( $this->_context->page );$page<1?1:$page;//设置每页显示的数量$page_size = 10;//按条件查找用户if($id = $this->_context->get('cus_id'))$cus_info->where('id = ?', $id);else{if($first_name = $this->_context->get('first_name'))$cus_info->where('first_name = ?', $first_name);if($last_name = $this->_context->get('last_name'))$cus_info->where('last_name = ?', $last_name);if($email = $this->_context->get('email'))$cus_info->where('email = ?', $email);if($code = $this->_context->get('code'))$cus_info->where('pro_id = ?', Program::find('code = ?', $code)->getOne()->id);}$cus_info->limitPage($page, $page_size);$cus = $cus_info->getAll();//渲染视图$this->_view['url_args'] = $this->_context->get();$this->_view['pagination'] = $cus_info->getPagination();$this->_view['cus'] = $cus;}
此代码中有一处是按条件查找用户,我们可以进行前台设计一个表单让用户输入特定条件来查找用户,代码如下:
<div class="pt10"><a href="javascript:;" onclick="javascript:$(this).parent().next('div').toggle();" title="search >">Search ></a></div><!--search--><div id="searchbox" style="display: none;" class="search_box"><a href="javascript:void(0);" onclick="javascript:$(this).parent().hide();" class="close2 f_r" title="close">close</a><form name="city_search_form" action="#" method="get"><p><label for="">Customer ID</label><input class="text" name="cus_id" type="text"></p><p><label for="">First Name</label><input name="first_name" class="text" type="text"></p><p><label for="">Last Name</label><input name="last_name" class="text" type="text"></p><p><label for="">Email Address</label><input name="email" class="text" type="text"></p><p><label for="">Program Code</label><input name="code" class="text" type="text"></p><p><label> </label><a onclick="city_search_form.submit();" title="" class="add_btn">Search</a></p></form></div><div class="paging pt10 txt_right"><?php echo $this->_control('page', 'p', array('pagination' => $pagination, 'url_args' => $url_args));?></div> <table class="pagetab mtb6" cellpadding="0" cellspacing="0" width="100%"><thead><tr><th width="10%">Cust. ID</th><th width="15%">First Name</th><th width="15%">Last Name</th><th width="20%">Email Address</th><th width="10%">Program</th><th width="25%">Last Login</th><th width="5%">Action</th></tr></thead><?php foreach ($cus as $cus):; ?><tbody><tr><td><?php echo $cus['id']; ?></td><td><?php echo $cus['first_name']; ?></td><td><?php echo $cus['last_name']; ?></td><td><?php echo $cus['email']; ?></td><td><?php echo $cus['program']['name']; ?></td><td><?php echo $cus['last_login_date']; ?></td><td><a href="<?php echo url('cus/cusdetail', array('id' => $cus['id']))?>" title="View">View</a></td></tr></tbody><?php endforeach; ?></table><div class="paging pt10 txt_right"><?php echo $this->_control('page', 'p', array('pagination' => $pagination, 'url_args' => $url_args));?></div>
分页关键代码为:
<?php echo $this->_control('page', 'p', array('pagination' => $pagination, 'url_args' => $url_args));?>
显示结果如图:
转载于:https://my.oschina.net/frylan/blog/64729
qeephp内容分页相关推荐
- 分页插件php,文章内容分页插件
应用信息 名称: 文章内容分页插件 售价: 128元 应用ID: NextPage 最低要求: Z-BlogPHP 1.5.2.1935 (Zero) Build 151935 版 本: 6.1 发布 ...
- php分页功能乱码了怎么办,51、PHP文件内容分页操作,避免乱码
新浪等一些大平台新闻网站经常使用内容分页技术,把一篇文章分成若干部分,每一部分作为其中一页,以这种形式展现给用户,不仅提升了用户体验,也提高了网站加载内容的效率,但是这种做法最大的问题就是在截取字符串 ...
- 帝国cms搜索php分页,帝国cms V7.2自定义分页(列表分页,内容分页)样式步骤
[1]自己修改帝国cms默认的分页样式(css),这样做的好处是你不用去改动帝国的核心文件,方便以后升级. [2]自己动手去修改帝国的分页(php+css),帝国的分页在e>class>下 ...
- 文章内容分页功能实现
文章内容分页,一篇文章内容过长,我们考虑内容分页显示.对于这个要求,得先从数据库设计角度来说,应该是一对多的关系.因此你需要设计两张表来存储文章的信息,第一张是基本的,如标题,摘要,作者等字段.另一个 ...
- php分页类smary,php新闻内容分页实例(smarty 模板)
项目需要用到 新闻内容页 实现分页功能,随便写了一下. 给大家做个参考,写的不好还望谅解啊! //新闻内容分页开始 The page next for news content start $next ...
- 含HTML标记的内容分页 (C#)
2009年3月27日23:52:20更新 最近网站要做静态生成内容必须分页所以在网上找了N多实例都不理想,所以花了点时间自己写了个方法 目前来说没发现什么问题(已用方法生成20W以上的html) 所以 ...
- 文章,记录按内容分页显示,根据文章内容按字数进行分页(转)
在很多时候我们对一些文章很长时,往往浏览时用鼠标滑来滑去非常麻烦.要是我们对这篇文章划分为几个 页面,用不同的面页去浏览不但看起来很爽,而且效率方面也是大的提高了. 下面是一段代码,给大家做个参考: ...
- html内容页上一页下一页,帝国CMS内容页增加内容分页上一页标签功能!
帝国CMS一直以来升级没有提供内容分页的上一页标签功能,只有一个:内容页下一页[!--next.page--] 标签!所以下面就是要改造一下这个标签,实现内容页上一页的功能! 步骤如下: 打开e/cl ...
- 火车头9.2 内容分页采集
火车头不同的版本设置有些不一样,从网上找的一些内容是一个老版本的,估计是7,8 版本,我这里用的是9.0.11.19版本,就是9版本吧.在网上找的一些设置截图都是不一样的.这里我讲下火车头采集9是如何 ...
最新文章
- 172. Factorial Trailing Zeroes
- ACM——模拟(hard) 刷题总结
- UVa1491 - Compress the String(dfs)
- adams齿轮齿条怎么定义接触_在SolidWorks里对标准齿轮、齿条的修改应用
- mybatis配置时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)...
- html复选框对齐文字,input【type=checkbox】标签与字体对齐
- python的全局变量能暂存数据吗_【Python】Python之全局变量
- Robolectric 探索之路
- Java程序设计之扑克牌
- 【Axure图标库】单线形图标元件库 细线矢量图标1000+
- Blake2b算法 php,Blake2b算法是什么?Blake2b算法币种盘点
- 浅谈CGI基本原理和底层基本实现
- 【android】集成腾讯的播放器SDK
- cpp简单实现一下RNN神经网络
- 子集全排列组合数问题(带你轻松拿捏十一道OJ题)
- Android开发之LitePal数据库的使用(参考于《Android 第一行代码》)
- SQL注入学习详细过程
- 用于光波导耦合的倾斜光栅分析
- 计算机英语图片素材,计算机编程英语素材.docx
- 疯狂Java联盟简介