PHP self-training project: Digital paging effect; php Training Project pagination

Source: Internet
Author: User

PHP self-training project: Digital paging effect; php Training Project pagination

Learning points:
1. LIMIT usage
2. Various parameters
3. hyperlink call

First, set the digital paging module in the file. My file is (blog. php)

// Paging module $ _ page =$ _ GET ['page']; $ _ pagesize = 10; $ _ pagenum = ($ _ page-1) * $ _ pagesize; // obtain the total data on the home page $ _ num = mysql_num_rows (_ query ("SELECT tg_id FROM tg_user"); $ _ pageabsolute =$ _ num/$ _ pagesize;

It should be noted that when the set is retrieved in the database

// We must re-read the result set each time instead of executing the SQL statement again.
$ _ Result = _ query ("SELECT tg_username, tg_sex, tg_face FROM tg_user order by tg_reg_time desc limit $ _ pagenum, $ _ pagesize ");
Set the effect of pagination Loop

<div id="page_num">    <ul>    <?php for($i=0;$i<$_pageabsolute;$i++){        if ($_page == ($i+1)) {            echo '<li><a href="blog.php?page='.($i+1).'" class="selected">'.($i+1).'</a></li>';        }else{            echo '<li><a href="blog.php?page='.($i+1).'">'.($i+1).'</li>';        }    } ?>    </ul>    </div>

Corresponding CSS

#page_num {height:20px;clear:both;padding:10px 0;position:relative;}#page_num ul {position:absolute;right:30px;height:20px;}#page_num ul li {float:left;width:26px;height:20px;}#page_num ul li a {display:block;width:20px;height:20px;line-height:20px;border:1px solid #333;text-align:center;text-decoration:none;}#page_num ul li a:hover,#page_num ul li a.selected {background:#666;font-weight:bold;color:#fff;}

  

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.