Home>Article>Web Front-end> Implement PDO paging and url rewriting
PDO (PHP Data Objects) defines a lightweight unified interface in PHP that can be used to access different types of databases.
Requirements
Write code to add a piece of data, PDO into the database (the title cannot be repeated
Paging function is implemented, page link Write a regex for list_page number.html
(regular link address) Create a new .htaccess with the next content
Displayed code
query($sql)->fetchAll(); //条数 $count = $count[0]['count(*)']; $limit = 3; //总页数 $numpage = ceil($count/$limit); //偏移量 $last = ($page-1)*$limit; if($page<1) { $page=1; return false; } if($page>$numpage) { $page=$numpage; return false; } $sql = "select * from text limit $last,$limit"; $data=$pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC); ?>Document
标题 | 作者 | 链接 | 内容 | 时间 |
Related recommendations:
php pdo insert and pdo insertId usage
The above is the detailed content of Implement PDO paging and url rewriting. For more information, please follow other related articles on the PHP Chinese website!