How to get the total number of pages in PHP

Source: Internet
Author: User
How to get the total number of pages in PHP
I have written a PHP page and I am now select * from user limit. ($page-1). ",". $rows can only get to the number of bars each time, I want to get a total of how many, how to obtain, now get is getrownum ();

function Getrownum ()
{
Return mysql_num_rows ($this->res);
}

Require_once ('.. /db/db.php ');
$db =new dataaccess ();
$con = $db->connect ();
$rows = $_post[' rows '];
$page = $_post[' page '];
$sql = "SELECT * from User Limit". ($page-1). ",". $rows; Paged SQL
$result = $db->query ($sql);
$row _num = $db->getrownum ();//can only get to the current number of bars



------Solution--------------------
The Select COUNT (*) from user needs to be executed individually
------Solution--------------------
Explore

Reference:

Paging is like this BT. I don't usually write it. I directly use the project to write the class, pass the value on the line.


Do not write does not mean that is not the implementation of it. It's just a modesty step, it's normal, you don't read the data from the database, how to know how many pieces of data to prepare the page ...

------Solution--------------------
Explore

Who has a ready-made way to share the best, thank you
  • 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.