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.