php資料分頁加資料顯示效果

來源:互聯網
上載者:User

<?php
include_once(dirname(__FILE__).'../../Inc/Conn.php');
include_once(dirname(__FILE__).'../../photo/Inc/function.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
<style type="text/css">
<!--
body,td,th {
 font-size: 12px;
 height:17px;
 padding:8px 0px 0px 0px;
 text-align:center;
 
}
body {
 margin-left: 0px;
 margin-top: 10px;
 margin-right: 0px;
 margin-bottom: 0px;
}
td{
 border:1px solid #333;
 }

-->
</style></head>

<body>
<div style="height:26px;text-align:left; width:98%;font-size:16px; font-weight:bold; margin:0px auto;"><a href="export.php" target="_blank">匯出Execel表格</a></div>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="8%"><strong>帳號</strong></td>
    <td width="14%"><strong>郵箱</strong></td>
    <td width="5%"><strong>性別</strong></td>
    <td width="9%"><strong>寶寶出生日期</strong></td>
    <td width="12%"><strong>省份</strong></td>
    <td width="9%"><strong>真實姓名</strong></td>
    <td width="12%"><strong>郵編</strong></td>
    <td width="10%"><strong>手機</strong></td>
    <td width="21%"><strong>地址</strong></td>
  </tr>
  <?php

    $sql  ="Select * from tablename";
  
    $result =mysql_query($sql) or die('fail1'.mysql_error());
    $rs  =mysql_fetch_array($result);
    $rdcount =mysql_num_rows($result);
    if($rdcount){
    $pagesize =20;
    $pagecount=($rdcount % $pagesize)?(int)($rdcount / $pagesize)+1:$rdcount/$pagesize;//統計總頁面
    $page  =isset($_GET['page'])?$_GET['page']:1;//取得當前頁面
    $start =($page>=1 && $page<=$pagecount)?$start=$pagesize*($page-1):$start=1;//取得超始記錄
    $start =$start;
    $sql  =$sql." order by add_date desc limit $start,$pagesize";
       
    $result =mysql_query($sql) or die(mysql_error());
  while($rs =mysql_fetch_array($result) ){    
   echo"<tr>
    <td>".$rs['User_Name']."</td>
    <td>".$rs['User_Mail']."</td>
    <td>".$rs['User_Baby_Sex']."</td>
    <td>".$rs['User_Baby_Birth']."&nbsp;</td>
    <td>".$rs['sheng']." &nbsp;</td>
    <td>".$rs['User_rname']." &nbsp;</td>
    <td>".$rs['User_Zip']." &nbsp;</td>
    <td>".$rs['User_Hand']." &nbsp;</td>
    <td>".$rs['User_Address']." &nbsp;</td>
     </tr>
     ";
  
  }
  echo "<tr> <td colspan=9>";
 pagelist1($page,$pagecount,$rdcount,'?page=',$pagesize);
 echo "</td> </tr> ";
 }else{
   echo '暫時沒有資訊!';
 }


function pagelist1($page,$pagecount,$totalrecord,$url,$pagesize)

 if($page=="" || $page>$pagecount)
 {
  $page=1;
 }
 echo("記錄".$totalrecord."條 每頁".$pagesize."條 共".$pagecount."頁 <a href=".$url."1>&nbsp;<<</a>&nbsp; ");
 if($page>1)
 { 
  echo("<a href=".$url.($page-1).">&nbsp;<&nbsp;</a> ");
 }  
 if($page+9>$pagecount)
 {
  $current = $pagecount; 
 }
 else
 { 
  $current = $page+9; 
 } 
 for($i=$page;$i<=$current;$i++)
 { 
  echo("<a href=".$url."$i class='sf'>$i</a> ");
 }
 if($pagecount>$page)
 {
  echo("<a href=".$url.($page+1).">&nbsp;>&nbsp;</a> ");
 } 
  echo("<a href=".$url.$pagecount.">&nbsp;>></a> ");
}
  ?>
 
</table>
</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.