Home>Article>Web Front-end> Implement PDO paging and url rewriting

Implement PDO paging and url rewriting

坏嘻嘻
坏嘻嘻 Original
2018-09-14 16:08:43 1529browse

PDO (PHP Data Objects) defines a lightweight unified interface in PHP that can be used to access different types of databases.

Requirements

  1. Write code to add a piece of data, PDO into the database (the title cannot be repeated

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

Implement PDO paging and url rewriting

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:

PDO--PHPDataObjects

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn