Mysql paging class (with paging function) _ PHP Tutorial

Source: Internet
Author: User
Tags mysql tutorial
Mysql paging class (with paging bar function ). Mysql tutorial paging class (with paging function) functionfenyezhixin ($ table, $ pagesize, $ paixu, $ do, $ wwhere) {if ($ tablenews_fabu) or ($ tableproduct_fabu) or ($ tablemes
/Mysql tutorial paging class (with paging function)
Function fenyezhixin ($ table, $ pagesize = "", $ paixu = "", $ do = "", $ wwhere = ""){
If ($ table = "news_fabu") or ($ table = "product_fabu") or ($ table = "message ") or ($ table = "down_fabu") or ($ table = "kucun ")){
$ Query = @ mysql_query ("select * from $ table $ wwhere ");
$ Pagesize = $ pagesize;
$ Sum = mysql_num_rows ($ query );
If ($ sum = 0 ){
$ Pagesize = 1;
}
If ($ pagesize = "0 "){
$ Sum = "1 ";
}
If (@ ($ sum % $ pagesize) = 0 ){
$ Total = @ (int) ($ sum/$ pagesize );
} Else {
$ Total = @ (int) ($ sum/$ pagesize) + 1;
}
If ($ total = 0) {$ total = 1 ;}
If (isset ($ _ get ['Page']) {
$ P = (int) $ _ get ['Page'];
} Else {
$ P = 1;
}
$ Start = $ pagesize * ($ p-1 );
$ Query = @ mysql_query ("select * from $ table $ wwhere order by $ paixu limit $ start, $ pagesize") or die ("Data query failed 2! ");
If ($ do = 1 ){
$ Queryarray = array ($ query, $ total, $ sum, $ p );
Return $ queryarray;
}
If ($ do = 2 ){
$ Parray = array ($ total, $ sum, $ p );
Return $ parray;
}
} Else {
$ Query = @ mysql_query ("select * from $ table $ wwhere order by $ paixu limit $ pagesize") or die ("Data query failed 1! ");
If ($ do = 1 ){
$ Queryarray = array ($ query, $ total, $ sum, $ p );
Return $ queryarray;
}
If ($ do = 2 ){
$ Parray = array ($ total, $ sum, $ p );
Return $ parray;
}
}
}
// Return pagination entries
Function fenyedaohang ($ total = "", $ sum = "", $ p = "", $ menut = ""){
$ W = substr ($ menut, strrpos ($ menut, "&") + 1, 2 );
$ Wr = substr ($ menut, strrpos ($ menut, "=") + 1, strlen ($ menut ));
$ Pindao = $ _ server ["script_name"]; $ pinstrlen = strrpos ($ pindao, "/"); $ pindao = substr ($ pindao, $ pinstrlen + 1, strlen ($ pindao ));
If ($ w = "pr "){
$ Queryr = mysql_query ("select feiye. feiye_what from feiye where feiye. feiye_page = '$ pindao '");
$ Rows = mysql_fetch_row ($ queryr); $ rrows = $ rows [0];
If (empty ($ rrows )){
Mysql_query ("insert into 'feiye '('feiye _ page', 'feiye _ Who') values (' $ pindao ',' $ wr ')");
Echo" ";
} Else {
If ($ wr! = $ Rrows ){
Mysql_query ("update 'feiye 'set' feiye _ what' = '$ wr' where ('feiye _ page' = '$ pindao ')");
Echo" ";
}
}
}
If ($ w = "ne "){
$ Queryr = mysql_query ("select feiye. feiye_what from feiye where feiye. feiye_page = '$ pindao '");
$ Rows = mysql_fetch_row ($ queryr); $ rrows = $ rows [0];
If (empty ($ rrows )){
Mysql_query ("insert into 'feiye '('feiye _ page', 'feiye _ Who') values (' $ pindao ',' $ wr ')");
Echo" ";
} Else {
If ($ wr! = $ Rrows ){
Mysql_query ("update 'feiye 'set' feiye _ what' = '$ wr' where ('feiye _ page' = '$ pindao ')");
Echo" ";
}
}
}
Echo "total ". "$ total ". "page ". "Record ". "$ sum ". "Current ". "$ p ". "/". "$ total ". "page ";
If ($ total = 1 ){
Echo "homepage ";
} Else {
Echo "homepage "."";
}
If ($ p> 1 ){
$ Prev = $ p-1;
Echo "previous page "."";
} Else {
Echo "previous page "."";
}
$ Page = $ _ get ["page"];
$ Pagesum = $ page + 5;
If ($ total> = 11 ){
If ($ pagesum <= 11 ){
$ Pagesum = 11;
}
}
If ($ pagesum >=$ total ){
$ Pagesum = $ total;
}
$ Pagestart = $ page-5;
If ($ pagestart <= 0 ){
$ Pagestart = 1;
}
If ($ total> = 11 and ($ total-4) <= $ page ){
$ Pagestart = $ total-10;
}
For ($ I = $ pagestart; $ I <= $ pagesum; $ I ++ ){
If ($ I = $ p ){
Echo "$ I ";
} Else {
Echo "$ I ";
}
}
If ($ p <$ total ){
$ Next = $ p + 1;
Echo "next "."";
} Else {
Echo "next "."";
}
If ($ total = 1 ){
Echo "last page ";
} Else {
Echo "last page ";
}
}

Callback paging class (with paging function) function fenyezhixin ($ table, $ pagesize =, $ paixu =, $ do =, $ wwhere =) {if ($ table = news_fabu) or ($ table = product_fabu) or ($ table = mes...

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.