<?php require_once("conn_inc.php"); //调用连接数据库 ?> <?php function fenye ($num,$pagecontent=3){ global $offect,$pagecontent; $url=$_SERVER['REQUEST_URI']; $url=parse_url($url); $url=$url[path]; $page=isset($_GET['page'])?intval($_GET['page']):1; $contentpage=ceil($num/$pagecontent); //一共有多少页 if ($page>=$contentpage) { $page=$contentpage; } if ($page<=0) { $page=1; } $offect=($page-1)*$pagecontent; //计算偏移量 $fist=1; //第一页 $next=$page+1; //下一页 $pre= $page-1; //上一页 $list=$contentpage; //最后一页 echo "一共 $num ||$page页 "; echo "<a href="$url?page=$fist" mce_href="$url?page=$fist">第一页</a> "; echo "<a href="$url?page=$next" mce_href="$url?page=$next">下一页</a> "; echo "<a href="$url?page=$pre" mce_href="$url?page=$pre">上一页</a> "; echo "<a href="$url?page=$list" mce_href="$url?page=$list">最后一页</a>"; } ?> <?php require_once("ye.php"); // 调用函数 ?> <?php include_once("display.php"); ?> <?php $query1=mysql_query("select id from login "); $num=mysql_num_rows($query1); fenye(7,$pagecontent=4); 函数传值 ?> <?php $query=mysql_query("select * from login order by id desc limit $offect,$pagecontent"); while ($row=mysql_fetch_array($query)) { ?> <table border="1" width="40%" height="10px"> <tr> <td width="100">用户名:</td> <td width="100"><?php echo $row[user]; ?></td> <td width="100">电子邮件:</td> <td width="100"><?php echo $row[mail]; ?></td> </tr> <tr> <td width="100">留言内容:</td> <td width="100" colspan="3"><?php echo $row[content]; ?></td> </tr> </table> <br> <?php } ?> 自己第一写函数,大家不要嘲笑我,哈哈!