PHP after the page, the serial number again to start the question + urgent

Source: Internet
Author: User
PHP after the page, serial number again start the problem + urgent urgent?
$MYSQL->query ("Select Cu.*,cy.name from Customer cu,custtype cy where 1=1 and Cu.code=cy.code limit 0,18");
for ($i =1; $i < $count; $i + +) {
$MYSQL->fetch ($i);
$customerid = $MYSQL->data[customerid]; Customer number
$KSName = $MYSQL->data[ksname]; User name-abbreviation
echo "$i"; Serial number
echo "$customerid"; Customer number
echo "$KSName"; User name-abbreviation
?>

I am every 18 records for a page, the first serial number is from 1-18, but I switch to the 2nd page, the serial number is from 1 to 18th, the same as the 3rd page, probably because I paged, I tried, if there is no problem, but here I can not page, Please do not have a good way to solve this problem.



PHP php? After the page change, the problem of serial number?

Share to:


------Solution--------------------
Set the desired page number to be passed in by $_get[' page '), there is

$offs = * Isset ($_get[' page ')? $_get[' page '-1:0;
$MYSQL->query ("Select Cu.*,cy.name from Customer cu,custtype cy where 1=1 and Cu.code=cy.code limit $offs, 18");

$MYSQL->fetch ($i);
$customerid = $MYSQL->data[customerid]; Customer number
$KSName = $MYSQL->data[ksname]; User name-abbreviation
echo "$i"; Serial number
echo "$customerid"; Customer number
echo "$KSName"; User name-abbreviation

------Solution--------------------
Citation:
#14, brother, you don't know, the problem, don't be nonsense. Ok!!!!!!!!!!

When you change the page number, it should be to get the URL of the incoming $page value, such as $_get[' page ';
Then, every time you page, there is a $page_size, your $page_size=18;
So, when you display on the page, the ID number of that list should be: ($page-1) * $page _size+ $i; The $i value is the subscript of the array.
 

$page =$_get[' page ';
$page _size=18;


$count = $MYSQL->query ("SELECT count (*) from Customer Cu,custtype Cy where 1=1 and Cu.code=cy.code");
  • 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.