Common data query and paging function module

Source: Internet
Author: User
Original post and discussion: original post and discussion: http://bbs.bccn.net/thread-182585-1-1.html#/ workshop */--------------------------------------------------------------------------------------
*/From: Programming China Http://www.bccn.net
*/Author: adleyliuE-mail: adleyliu@163.comQQ: 14339095
*/Time:-11-1 Programming Forum debut
*/Statement: respect the work of the Author. reprinted in this section.
*/Configure */--------------------------------------------------------------------------------------

#*************************************** ******************
# File name: inc_funceion.php
# Function description: Common Data Query and paging function module
# Program production: print (adleyliu)
# Contact qq: 14339095
# Contact Email: Adleyliu@163.com
# Official website: Http://www.115000.com.cn
# Copyright (c) 2007-2008 oblog.cn all rights reserved.
# Last update: 2007-10-30
#*************************************** ******************#********************* ************************************
# Exploitation start
#*************************************** ******************
$ Yl_class = new yl_class ();
$ Type_functionname = 'list _ info_admin '; // the function name of the cyclic list. (for example, you can recreate a class or directly modify the list_info_main_obj style in the original class)
$ Pageurl = 'admin _ article_list.php? '; // If the information List page contains a category, other parameters: 'admin _ article_list.php? Nid = '. $ nid .'&'
$ Action = $ _ POST ['action']? $ _ POST ['action']: $ _ GET ['action']; // submit for other efficacy applications
$ Getpage = $ _ POST ['Page']? $ _ POST ['Page']: $ _ GET ['Page']; // receives the jump page number.
$ Pageumn = 30; // The number of entries displayed on each page
$ Selecttable = 'yl _ info'; // data table
$ Selectwhere = 'Where yl_sh = 1'; // query condition
$ Selectstr = 'yl _ id, yl_title, yl_adddate, '; // fields to be queried
$ Orderbystr = 'yl _ adddate desc '; // sorting rule
$ Yl_dbname = $ dbname // Database

$ List_str = $ yl_class-> list_select ($ type_functionname, $ pageurl, $ getpage, $ pageumn, $ selecttable, $ selectwhere, $ selectstr, $ orderbystr, $ yl_dbname );
#*************************************** ******************
# Display List
#*************************************** ******************
Echo '';

#*************************************** ******************
# End of exploitation
#*************************************** ******************
#*************************************** ******************
# Without the PHP environment, you can view the message system for printing images (asp) Www.115000.com.cn
#*************************************** ******************
/* No need to say how to apply a paging style sheet */
/*
. PageNum {
CLEAR: both; WIDTH: '000000'; PADDING-RIGHT: 5px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; PADDING-BOTTOM: 0px; OVERFLOW: hidden; COLOR: #6396D6; PADDING-TOP: 0px; HEIGHT: 25px;
}
. PageNum. num {
FLOAT: right;
}
. PageNum. normal {
BACKGROUND: # F7FBFF; COLOR: #6396D6; FLOAT: left; PADDING-BOTTOM: 2px; MARGIN: 0px 3px 0px 0px; PADDING-TOP: 3px; BORDER-LEFT: #6396D6 1px solid; BORDER-RIGHT: #6396D6 1px solid; PADDING-RIGHT: 5px; PADDING-LEFT: 5px; BORDER-TOP: #6396D6 1px solid; BORDER-BOTTOM: #62.16d6 1px solid;
}
. PageNum. dot {
FLOAT: left; COLOR: #62.16d6;
}
. PageNum {
BACKGROUND: #298AC6; COLOR: # fff; FLOAT: left; PADDING-BOTTOM: 2px; MARGIN: 0px 3px 0px 0px; PADDING-TOP: 3px; BORDER-LEFT: #6396D6 1px solid; BORDER-RIGHT: #6396D6 1px solid; PADDING-RIGHT: 5px; PADDING-LEFT: 5px; BORDER-TOP: #6396D6 1px solid; BORDER-BOTTOM: #62.16d6 1px solid;
}
. PageNum A: visited {
COLOR: # fff;
}
. PageNum A: hover {
BACKGROUND: # F7FBFF; COLOR: #6396D6; BORDER-LEFT: #6396D6 1px solid; BORDER-RIGHT: #6396D6 1px solid; BORDER-TOP: #6396D6 1px solid; BORDER-BOTTOM: #610000d6 1px solid;
}
*/
#*************************************** ******************
# The following two classes can be retained as a file
#*************************************** ******************
Class yl_class_sys
{
#*************************************** ******************
# The Data List class uses the object method
#*************************************** ******************
Function list_info_main_obj ($ rs, $ pagesize, $ resultstr ){
$ Leftline0 ='
    ';
    $ List_info = $ leftline0;
    $ I = 0;
    While ($ rs = fetch_object ($ resultstr )){
    $ Yl_id = $ rs-> yl_id;
    $ Yl_ttle = $ rs-> yl_title;
    $ Yl_adddate = $ rs-> yl_adddate;

    $ List_info. ='
  • ';
    $ List_info. = '[';
    $ List_info. = ''. $ yl_adddate .'';
    $ List_info. = ']';
    $ List_info. = ''. $ yl_ttle .'';
    $ List_info. ='
  • ';
    If ($ I % 5) = 0 ){
    $ Leftline1 ='
'. $ Leftline0 .'';
$ List_info. = $ leftline1;
}
$ I;
If ($ I> $ pagesize)
Break;
Else
Continue;
}
$ List_info. ='';
Return $ this-> list_info_main_obj = $ list_info;
}
#*************************************** ******************
# Paging navigation
#*************************************** ******************
Function list_page ($ pageurl, $ rsnum, $ pages, $ pagecount, $ pagesize ){
$ Pcount = $ pages;

$ Page_info = '';
$ Page_info. = '';
If ($ pcount> 1) & ($ pcount = $ pagecount )){
$ Page_info. = 'previous page ';
} Elseif ($ pagecount! = 1) & ($ pcount! = $ Pagecount )){
$ Page_info. = 'previous page ';
}
$ Page_info. = 'front ';
If ($ pagecount> 4 ){
$ Page_info. = '';
}
}
}
If ($ pagecount 2 <$ pcount ){
$ Page_info. = '... ['. $ pcount. ']';
}
$ Page_info. = 'footer ';
If ($ pagecount = 1) & ($ pcount! = $ Pagecount) & ($ pcount! = 0 )){
$ Page_info. = 'next page ';
} Else if ($ pagecount! = 1) & ($ pcount! = $ Pagecount )){
$ Page_info. = 'next page ';
}
$ Page_info. = ''; $ page_info. = '';
$ Page_info. = 'Total: '. $ rsnum.' bar/'. $ pcount.' page/'. $ pagesize.' bar ';
$ Page_info. = '';
// Echo '';
$ Page_info. = '';
$ Page_info. = '';

Return $ this-> list_page = $ page_info;
} Class yl_class {
#*************************************** ******************
# Data Query
#*************************************** ******************
Function list_select ($ type_functionname, $ pageurl, $ getpage, $ pageumn, $ selecttable, $ selectwhere, $ selectstr, $ orderbystr, $ yl_dbname)
{
$ Yl_class_sys = new yl_class_sys ();
If ($ pageumn = ''){
$ Pageumn = 10;
}
If ($ selecttable = ''){
$ Selecttable = 'yl _ info ';
}
If ($ selectstr = ''){
$ Selectstr = '*';
}
If ($ orderbystr = ''){
$ Selectstr = 'yl _ adddate desc ';
}
$ Sqlsrt = 'select'. $ selectstr. 'from'. $ selecttable. ''. $ selectwhere. 'Order by'. $ orderbystr .'';
$ Resultstr = db_query ($ yl_dbname, $ sqlsrt );
If (! $ Resultstr ){
Echo 'very negative, query failed. the database may be protected. please try again later ';

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.