1. 云栖社区>
  2. PHP教程>
  3. 正文

php 分页1

作者:用户 来源:互联网 时间:2017-12-01 13:34:54

php

php 分页1 - 摘要: 本文讲的是php 分页1,<?php /** * 用户列表 * kcj * 2011/8/20 * */ include "../conn/conn.php"; $sql="select * from user"; $rst=mysql_query($sql)

<?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> 
<p id="main"> 
  后台管理->用户列表 
   <form  method="post" action=""   > 
<p 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>  
</p> 
                    </form> 
</p> 
</body> 
</html> 

摘自 chaojie2009的专栏

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索php ,以便于您获取更多的相关知识。