时间:2021-07-01 10:21:17 帮助过:38人阅读
// 确定当前页数 $p 参数$p = $_GET['p']?$_GET['p']:1;// 数据指针$offset = ($p-1)*$pagesize;$query_sql = "SELECT * FROM guestbook ORDER BY id DESC LIMIT $offset , $pagesize";$result = mysql_query($query_sql);// 如果出现错误并退出if(!$result) exit('查询数据错误:'.mysql_error());// 循环输出while($gb_array = mysql_fetch_array($result)){?>
=$gb_array['nickname']?> [=date("Y-m-d H:i", $gb_array['createtime'])?>]
=nl2br($gb_array['content'])?>
管理员回复: [=date("Y-m-d H:i", $gb_array['replytime'])?>]
=nl2br($gb_array['reply'])?>
1) { for($i=1;$i<=$pagenum;$i++) { if($i==$p) { echo ' [',$i,']'; } else { echo ' '.$i.''; } }}?>
CREATE TABLE `guestbook` ( `id` mediumint(8) unsigned NOT NULL auto_increment, `nickname` char(16) NOT NULL, `email` varchar(60) default NULL, `face` tinyint(2) unsigned NOT NULL default '1', `content` text NOT NULL, `createtime` int(10) unsigned NOT NULL default '0', `clientip` char(15) NOT NULL, `reply` text, `replytime` int(10) unsigned default NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
$_GET['p'] 是传入的变量,第一次执行就不会有,所以会报错
$p = isset($_GET['p']) ? $_GET['p'] : 1;