PHP article List page code how to write?

Source: Internet
Author: User
$sql = "Select * from ' Links ' WHERE ' subdomain '! = '" ORDER by id desc LIMIT "; $rows = $db->getdata ($sql); foreach ($r oWS as $row) {echo '
  • '. $row [' title ']. '
  • ';}

    The first page of the article call I will write, but to pagination do not know how to write
    There is now a field title subdomain


    Reply to discussion (solution)

    Just find a page function to apply it.
    The approximate parameters are as follows:
    1 Total
    2 Current Page
    3 Quantity per page
    4 BaseUrl, the title and the subdomain you say are sent in get mode.
    5 Display number of pages

    Class Ccustomwidgets {public static function Pager ($totalPages, $pageNumber, $pageSize, $url, $displayNumber = 6) {$ BASEURL = (Strpos ($url, "?") = = = = False)? $url. '? Page= ': $url. '    &page= '; $pager = '
     
     
      '; $prevPage = $pageNumber-1; if ($prevPage > 0) {$pager. = '
    • ĸ?ä¸?页
    • '; } if ($totalPages-$pageNumber < $displayNumber) {$displayStart = ($totalPages >= $displayNumber)? ($totalPages-$displayNumber + 1): 1; $displayEnd = $totalPages; }else{if ($pageNumber% $displayNumber) {$displayStart = Floor ($pageNumber/$displayNumber) * $displayNumber + 1; $displayEnd = (Floor ($pageNumber/$displayNumber) + 1) * $displayNumber; }else{$displayStart = (Floor (($pageNumber/$displayNumber)-1) * $displayNumber + 1; $displayEnd = (Floor ($pageNumber/$displayNumber)) * $displayNumber; }} for (; $displayStart <= $displayEnd; $displayStart + +) {$pager. = '
    • '. $displayStart. '
    • '; } if ($pageNumber < $totalPages) {$pager. = '
    • ĸ?ä¸?页
    • '; } $pager. = "
    "; return $pager; }}

    If your paging is to be done on the database, these two fields are not enough, you only have the title and part of the article. At least you have to identify this domain is the first paragraph/page of the article and the ID title of the identity article can be repeated

    Is the complexity of paging logic.

    The main use of SQL Limi statement to page, pass two parameters, a start page, a display number per page.
    At the front desk, if you don't use a brushless, you can use the address get value to the page, and then change the content based on the value of get.
    Do a brushless, $.post the page number to action, and then handle it in action.
    The callback function then replaces the DIV content.

  • 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.