Project Structure:
Operating effect:
conn.php
Copy the Code code as follows:
$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", "
", Str_replace (" "," ", $content));
return $content;
}
?>
page.php
Copy the Code code as follows:
1 2
3 function _pageft ($totle, $displaypg = A, $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 take out the URL separately
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;
Start Page navigation bar code:
$pagenav = "Show" . ($totle? ($firstcount + 1): 0). "-" . Min ($firstcount + $DISPLAYPG, $totle). "Records, a total of $totle records ";
If only one page jumps out of the function:
if ($LASTPG <= 1)
return false;
$pagenav. = "Home";
if ($PREPG)
$pagenav. = "front page";
Else
$pagenav. = "front page";
if ($NEXTPG)
$pagenav. = "Back Page";
Else
$pagenav. = "Back Page";
$pagenav. = "Last";
Drop-down Jump List, looping through all page numbers:
$pagenav. = "To$i \ n "; else $pagenav. = "$i \ n "; } $pagenav. = "Page, total $lastpg page ";
}
Include ("conn.php");
$result =mysql_query ("SELECT * from ' Test ');
$total =mysql_num_rows ($result);
Call Pageft (), displaying 10 messages per page (this parameter can be omitted using the default 20 o'clock), using the 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 "". $row [name]." | ". $row [Sex];
}
?>
list.php
[Code]
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 ($_getCurrent 1/3 page 123 next page
The above describes the realization of the Chinese Dream Experience PHP Development page implementation code 1th/3, including the realization of the Chinese Dream experience aspects of the content, I hope that the PHP tutorial interested in a friend helpful.