How to make the php database table id show the sequence number increasing from 1 on the webpage

Source: Internet
Author: User
How does one set the id of the php database table to auto-increment in the database table with an ascending sequence starting from 1 on the webpage? however, sometimes data insertion fails or the id is inconsistent after data deletion.
I want to display each piece of data 1, 3, 4, 5, 6... in this order when outputting a webpage.

I tried to display a single page. The problem is that my data is displayed in the paging limit statement paging mode.
When the second page is displayed, it starts from 1 2 3 4 5...

This is not a simple question. please give me some advice.


Reply to discussion (solution)

You do not want to modify the table id, but display the continuous sequence number when displaying it.
Is that the case?
Sequence Number initial value = (page number-1) * Number of lines per page + 1

Yes, the page number is calculated. the id is used in the hyperlink of the post. the hyperlink of the page number is only page = xxx.

The first page is 1-10, the second page is 11-20, that is, the initial value (2-1) * 10, and then the output data cyclically. the sequence number also increments by 1.

Take a look at the paging class example and you will know how many pages are obtained by dividing the total number by the number of pages on each page, and the pages are listed cyclically.

That's it ~

You do not want to modify the table id, but display the continuous sequence number when displaying it.
Is that the case?
Sequence Number initial value = (page number-1) * Number of lines per page + 1

In this way, the initial value of each page is = (current page number-1) * number of records per page + 1

For a smart template, you can also use the built-in functions of smarty: used to record the number of entries displayed on the {$ v @ iteration} page.
Iteration is the number of current cycles. Unlike index, iteration starts from 1. Iteration will add one in each loop.

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.