当前位置:编程学习 > php >>

php 分页1

<?php 
/**
 * 用户列表
 * kcj
 * 2011/8/20
 * */ 
include "../conn/conn.php"; 
$sql="select * from user"; 
$rst=mysql_query($sql); 
$totalnum=mysql_num_rows($rst); 
$pagesize=2; 
$page=$_GET['page']; 
if($page==''){ 
$page=1; 

$pagecount=ceil($totalnum/$pagesize); 
$bingage=($page-1)*$pagesize; 
?> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>无标题文档</title> 
<meta name="Author" content="kcj" /> 
<meta name="Keywords" content="php,lampbrother" /> 
<link rel="stylesheet" type="text/css" href="style/lampcms.css"> 
<script src="javascript/common.js"></script> 
</head> 
<body> 
<div id="main"> 
  后台管理->用户列表 
   <form  method="post" action=""   > 
<div class="msg-box"> 
<ul class="viewmess"> 
<li class="dark-row"> 
<span class="list_width width_font">用户名</span> 
<span class="list_width width_font" style="width:200px">备注名</span> 
<span class="list_width width_font">注册时间</span> 
<span class="list_width width_font">操  作</span> 
</li> 
      
<li class="light-row" style="padding-top:2px; padding-bottom:2px"> 
  <?php 
 $sql="select * from user order by id asc limit $bingage,$pagesize"; 
  $rst=mysql_query($sql); 
  while ($row=mysql_fetch_array($rst)){ 
  ?> 
<span class="list_width"><?php echo $row['username'];?></span> 
 
<span class="list_width" style="width:200px"><?php echo $row['rname'];?></span> 
<span class="list_width"><?php echo $row['ctime'];?></span> 
 
<span class="list_width" style="width:160px;"> 
   
【<a href="main.php?action=addUser&edit=mod&id=<{ $users[doc].id }>">修改</a>】 
<?php if($row['id']!=1){?> 
【<a onclick="return confirm('确定要删除用户<{ $users[doc].userName }>吗?')" href="main.php?action=editUser&page=<{ $pageInfo.current_page }>&id=<{ $users[doc].id }>&edit=del">删除</a>】 
<?php }?> 
</span> 
<? 
  } 
?> 
</li> 
 
 
<li class="dark-row"> 
<span class="col_width" style="margin-left:15px;width:240px;">  
  共<?php echo $totalnum;?>条;  共<?php echo $pagecount;?>页;  每页显示<?php echo $pagesize;?>条 
<a href="<?php echo $_SERVER['PHP_SELF']?>?page=1">首页</a> 
  <?php 
  for ($i=1;$i<=$pagecount;$i++){ 
  echo "<a href=".$_SERVER['PHP_SELF']."?page=$i".">【".$i."】</a>"; 
  } 
   
 ?> 
<a href="<?php echo $_SERVER['PHP_SELF']."?page=".$pagecount;?>">尾页</a> 
</span> 
</li> 
</ul>  
</div> 
                    </form> 
</div> 
</body> 
</html> 

摘自 chaojie2009的专栏
补充:Web开发 , php ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,