Project structure:
Operation Effect:
conn.php
Copy Code code as follows:
<?php
$conn = @ mysql_connect ("localhost", "root", "") or Die ("Database link error");
mysql_select_db ("form", $conn);
mysql_query ("Set names ' GBK '"); Use GBK Chinese code;
Replace space, enter
function Htmtocode ($content) {
$content = Str_replace ("\ n", "<br>", Str_replace ("", "", $content));
return $content;
}
?>
page.php
Copy Code code as follows:
1 <?php
2
3 function _pageft ($totle, $displaypg = $url = ') {
4
5 Global $page, $firstcount, $pagenav, $_server;
6
7 $GLOBALS ["displaypg"] = $DISPLAYPG;
8
9 if (! $page)
$page = 1;
if (! $url) {
$url = $_server["Request_uri"];
}
URL Analysis:
$parse _url = Parse_url ($url);
$url _query = $parse _url["Query"]; Query string to remove URL individually
if ($url _query) {
$url _query = ereg_replace ("(^|&) page= $page", "", $url _query);
$url = Str_replace ($parse _url["Query"), $url _query, $url);
if ($url _query)
$url. = "&page";
Else
$url. = "page";
} else {
$url. = "? page";
}
$LASTPG = Ceil ($totle/$DISPLAYPG); Last page, also the total number of pages
$page = min ($lastpg, $page);
$PREPG = $page-1; Previous page
$NEXTPG = ($page = = $LASTPG 0: $page + 1); Next page
$firstcount = ($page-1) * $DISPLAYPG;
To start the pager bar code:
$pagenav = "Show <B>". ($totle? ($firstcount + 1): 0). "</B>-<B>". Min ($firstcount + $DISPLAYPG, $totle). "</B> Records, a total of $totle records";
If only one page jumps out of the function:
if ($LASTPG <= 1)
return false;
$pagenav. = "<a href= ' $url =1 ' > Home </a>";
if ($PREPG)
$pagenav. = "<a href= ' $url = $prepg ' > front page </a>";
Else
$pagenav. = "front page";
if ($NEXTPG)
$pagenav. = "<a href= ' $url = $nextpg ' > Back page </a>";
Else
$pagenav. = "Back Page";
$pagenav. = "<a href= ' $url = $lastpg ' > Last </a>";
Drop-down Jump List, looping through all page numbers:
$pagenav. = "to <select name= ' topage ' size= ' 1 ' onchange= ' window.location=\" $url =\ "+this.value ' >\n";
for ($i = 1; $i <= $lastpg; $i + +) {
if ($i = = $page)
$pagenav. = "<option value= ' $i ' selected> $i </option>\n";
Else
$pagenav. = "<option value= ' $i ' > $i </option>\n";
}
$pagenav. = "</select> page, total $lastpg page";
}
Include ("conn.php");
$result =mysql_query ("SELECT * from ' Test '");
$total =mysql_num_rows ($result);
Call Pageft (), display 10 messages per page (using the default 20 o'clock, you can omit this parameter), use this page URL (default, so omitted).
_pageft ($total, 5);
Echo $pagenav;
$result =mysql_query ("SELECT * from ' Test ' limit $firstcount, $displaypg");
while ($row =mysql_fetch_array ($result)) {
echo "}
?>
list.php
[Code]
<?php
Include ("conn.php");
$pagesize = 5;
$url =$_server["Request_uri"];
$url =parse_url ($url);
$url = $url [path];
$NUMQ =mysql_query ("SELECT * from ' Test '");
$num = mysql_num_rows ($NUMQ);
if ($_get
Current 1/3 page 123 Next read the full text