PHP Paging Code

Source: Internet
Author: User


Include ("conn.php");
Fetch URL Value
$pagesize = 10;
$url =$_server["Request_uri"];
$url =parse_url ($url);
$url = $url [path];
$total _row=mysql_num_rows (mysql_query ("SELECT * from Data_test")); Take the total number of bars if ($_get[page]) {
$pagevalue =$_get[page];
$page = ($pagevalue-1) * $pagesize;
$page. =,;
}
$pagenum =ceil ($total _row/$pagesize); Fetch page page echo "<table width=792 height=56 border=0 cellspacing=1>";
echo "<tr bgcolor= #9999FF >";
echo "<th width=33 scope=col>id</th>";
echo "<th width=91 scope=col>trans_type</th>";
echo "<th width=86 scope=col>trans_amt</th>";
echo "<th width=113 scope=col>trans_date</th>";
echo "<th width=68 scope=col>sinage</th>";
echo "<th width=246 scope=col>insert_date</th>";
echo "<th width=109 scope=col>note</th>";
echo "</tr>"; $all _sql = "SELECT * from Data_test limit $page $pagesize"; $query = mysql_query ($all _sql);
while ($row = Mysql_fetch_array ($query)) {
echo "<tr bgcolor= #99FF00 >";
echo "<td> $row [0]</td>";
echo "<td> $row [1]</td>";
echo "<td> $row [2]</td>";
echo "<td> $row [3]</td>";
echo "<td> $row [4]</td>";
echo "<td> $row [5]</td>";
echo "<td> $row [6]</td>";
echo "</tr>";
}echo "</table>";
if ($total _row>= $pagesize) {//Determines whether the total number of records is greater than the number of bars per page
echo "<a href= $url? page=". ($pagevalue =1). " > Home </a> ";
}
for ($i =1; $i <= $pagenum; $i + +) {//Loop page pages
$show = "<a href= $url? page=". ($i). " > $i </a> ";
echo $show. "";
if ($i >= $pagenum) {//Determines whether page pages show end
echo "<a href= $url? page=". ($i-1). " > End </a> ";
}
echo Total. $total _row. Article per page total. $pagesize. Article current section $page. >

PHP Paging Code

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.