时间:2021-07-01 10:21:17 帮助过:3人阅读
php与ajax结合实现的无刷新分页的简单例子,供初学的朋友参考。
无刷新分页,兼容IE与Firefox等浏览器。 1、index.php
2、sql.php ".$row["uname"].""; } $num=mysql_num_rows(mysql_query("select * from test")); $pagenum=@ceil($num/$pagesize); for($i=1;$i<=$pagenum;$i++){ if($page==$i){ $str.="[".$i."] "; }else{ $str.="".$i." "; } } echo $str; }else{ die(); } ?> 3、test数据库 test表 SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for test -- ---------------------------- DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `id` int(10) NOT NULL auto_increment, `uname` char(50) character set utf8 NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=gb2312 COLLATE=gb2312_bin; -- ---------------------------- -- Records -- ---------------------------- INSERT INTO `test` VALUES ('1', 'aaaaaaaaaaa'); INSERT INTO `test` VALUES ('2', 'bbbbbbbbbbbb'); INSERT INTO `test` VALUES ('3', 'cccccccccccc'); INSERT INTO `test` VALUES ('4', 'dddddddddddddddd'); INSERT INTO `test` VALUES ('5', 'eeeeeeeeeee'); INSERT INTO `test` VALUES ('6', 'ffffffffff'); INSERT INTO `test` VALUES ('7', 'ggggggggggggggg'); INSERT INTO `test` VALUES ('8', 'hhhhhhhhhhhh'); INSERT INTO `test` VALUES ('9', 'jjjjjjjjjjjjjjjj'); INSERT INTO `test` VALUES ('10', 'kkkkkkkkkkk'); INSERT INTO `test` VALUES ('11', 'mmmmmmmmmmm'); INSERT INTO `test` VALUES ('12', 'cccccccccccccccccc'); INSERT INTO `test` VALUES ('13', 'bbbbbbbbbbbb'); INSERT INTO `test` VALUES ('14', 'ooooooooooooooooo'); INSERT INTO `test` VALUES ('15', 'pppppppppppp'); INSERT INTO `test` VALUES ('16', 'aaaaaaaaaaaaaaa'); INSERT INTO `test` VALUES ('17', 'ggggggggggggggggg'); INSERT INTO `test` VALUES ('18', 'dddddddddddddddd'); INSERT INTO `test` VALUES ('19', 'cccccccccccccc'); INSERT INTO `test` VALUES ('20', 'xxxxxxxxxx'); INSERT INTO `test` VALUES ('21', 'zzzzzzzzzzzzzzz'); INSERT INTO `test` VALUES ('22', 'oooooooooooooooooooo'); INSERT INTO `test` VALUES ('23', 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'); INSERT INTO `test` VALUES ('24', 'uuuuuuuuuuuuuuuuuuuuuuuuuuuuu'); INSERT INTO `test` VALUES ('25', 'yyyyyyyyyyyyyyyyyy'); INSERT INTO `test` VALUES ('26', 'ttttttttttttttttttttttttttt'); INSERT INTO `test` VALUES ('27', 'rrrrrrrrrrrrrrrrrrrrrrrr'); INSERT INTO `test` VALUES ('28', 'eeeeeeeeeeeeeeeeeeeee'); INSERT INTO `test` VALUES ('29', 'wwwwwwwwwwwwwwwwwwwww'); INSERT INTO `test` VALUES ('30', 'qqqqqqqqqqqqq'); |