ThinkPHP + Ajax 局部刷新问题

浏览:4794 发布日期:2015/09/21 分类:求助交流 关键字: ThinkPHP Ajax 无刷新
我这里有这张表: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();
    }
}
但是,页面中有两个按钮, 《上一个》 《下一个》。
我想点击《上一个》按钮,无刷新查询上一条结果,并且在 页面上显示出来;
点击《下一个》按钮,无刷新查询吓一条结果,并且在 页面上显示出来。


这个应该怎么实现?
最佳答案
评论( 相关
后面还有条评论,点击查看>>