PHP Data paging and data display effect

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags data data paging display echo function html http paging

<?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= "HTML; charset=gb2312 "/>
<title> Untitled Document </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" > Export execel table </a></div>
<table width= "cent" border= "0 "align=" center "cellpadding=" 0 "cellspacing=" 0 "
  <tr>
    <td width=" 8% " ><strong> account </strong></td>
    <td width= "14%" ><strong> mailbox </ Strong></td>
    <td width= "gros" ><strong> gender </strong></td>
    <td width= "gros" ><strong> baby Birth date </strong></td>
    < TD width= "12%" ><strong> province </strong></td>
    <td width= "gros" >< strong> real name </strong></td>
    <td width= "12%" ><strong> zip code </strong ></td>
    <td width= "calculated" ><strong> cell phone </sTrong></td>
    <td width= "21%" ><strong> address </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;//Statistics Total page


$page =isset ($_get[' page ')? $_get[' page ']:1;//get the current page


$start = ($page &gt;=1 &amp;&amp; $page &lt;= $pagecount)? $start = $pagesize * ($page-1): $start =1;//get a record


$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 "&lt;tr&gt;


&lt;td&gt; ". $rs [' user_name ']." &lt;/td&gt;


&lt;td&gt; ". $rs [' User_mail ']." &lt;/td&gt;


&lt;td&gt; ". $rs [' User_baby_sex ']." &lt;/td&gt;


&lt;td&gt; ". $rs [' User_baby_birth ']." &amp;nbsp;&lt;/td&gt;


&lt;td&gt; ". $rs [' Sheng ']." &amp;nbsp;&lt;/td&gt;


&lt;td&gt; ". $rs [' User_rname ']." &amp;nbsp;&lt;/td&gt;


&lt;td&gt; ". $rs [' User_zip ']." &amp;nbsp;&lt;/td&gt;


&lt;td&gt; ". $rs [' User_hand ']." &amp;nbsp;&lt;/td&gt;


&lt;td&gt; ". $rs [' user_address ']." &amp;nbsp;&lt;/td&gt;


&lt;/tr&gt;


     ";


  


  }


echo "&lt;tr&gt; &lt;td colspan=9&gt;";


Pagelist1 ($page, $pagecount, $rdcount, '? page= ', $pagesize);


echo "&lt;/td&gt; &lt;/tr&gt;";


}else{


Echo ' temporarily no information! '


 }


Function Pagelist1 ($page, $pagecount, $totalrecord, $url, $pagesize)

 if ($page = = "" | | $page > $pagecount)
 {
   $page =1
 
 echo (Records. $totalrecord. " Per page ". $pagesize." "$pagecount." Page <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; &NBSP
 
 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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.