php分页代码简单实现_简单PHP分页

php分页代码简单实现

As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to make it as simple as possible and as short as possible AND so we all can reach for it at EE.

随着本主题以不同形式反复出现,我终于决定写一篇简短的(是的,对的...)有关使用MySQL数据库与PHP分页的文章/教程。 我知道有数十种此类教程-我想使其尽可能简单和尽可能短,因此我们都可以在EE上找到它。

First of all - the preparations. I assume you have your Apache + PHP set up (by XAMPP / WAMP / any other).

首先-准备。 我假设您已经设置了Apache + PHP(通过XAMPP / WAMP /任何其他方式)。

1. What you need is one file - lets name it.... hmmm.... index.php ! Place it under a directory of your choice.

1.您只需要一个文件-命名为... hmmm .... index.php! 将其放在您选择的目录下。

2. Let's setup a database. If you use phpmyadmin, you know what to do - import the script creating the "pagination" table. I have created a database named "test" for it.

2.让我们建立一个数据库。 如果您使用phpmyadmin,则知道该怎么做-导入创建“分页”表的脚本。 我已经为其创建了一个名为“ test”的数据库。

CREATE TABLE IF NOT EXISTS `pagination` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;

Just the 'id' and 'name' (simple, simple, simple,...) fields. This is the data for the table:

只是“ id”和“ name”(简单,简单,简单...)字段。 这是表的数据:

INSERT INTO `pagination` (`id`, `name`) VALUES
(1, 'one'),
(2, 'two'),
(3, 'three'),
(4, 'four'),
(5, 'five'),
(6, 'six'),
(7, 'seven'),
(8, 'eight'),
(9, 'nine'),
(10, 'ten'),
(11, 'eleven'),
(12, 'twelve'),
(13, 'thirteen'),
(14, 'fourteen'),
(15, 'fifteen'),
(16, 'sixteen'),
(17, 'seventeen'),
(18, 'eighteen'),
(19, 'nineteen&
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值