CREATE TABLE IF NOT EXISTS `sj_gongsi` (
`gid` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
`gname` varchar(120) NOT NULL DEFAULT '',
`sort` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`gid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
INSERT INTO `sj_gongsi` (`gid`, `gname`, `sort`) VALUES
(1, '1建设工程项目管理咨询有限公司', 1),
(2, '2工程造价咨询有限公司', 2),
(3, '3工程项目管理咨询有限公司', 3),
(4, '4工程造价咨询有限公司', 4),
(5, '5工程造价咨询有限公司', 0),
(6, '5建设工程项目管理有限公司喀什分公司', 0);我在页面中通过 gid 在页面显示相应的公司名称。浏览 http://localhost/2015/index.php/Index/Index/index/id/1 这个地址能看到第一个公司名称。
具体代码:
public function index(){
$id = isset($_GET['gid']) && !empty($_GET['gid']) ? $_GET['gid'] : 1;
$cid = isset($_GET['cid']) && !empty($_GET['cid']) ? $_GET['cid'] : 1;
$num = count($this->db->getAll());
if($gid>$num){
$this->error('您已经做完了本套题库',U('index',array('gid'=>1)));
}else{
$data = $this->db->where(array('cid'=>$cid))->one($gid);
$this->assign('data',$data);
$this->display();
}
}但是,页面中有两个按钮, 《上一个》 《下一个》。我想点击《上一个》按钮,无刷新查询上一条结果,并且在 页面上显示出来;
点击《下一个》按钮,无刷新查询吓一条结果,并且在 页面上显示出来。
这个应该怎么实现?
最佳答案