niko craft
niko craft

Reputation: 2977

how would I add index to all returned results when using pagination

I want to give index to each result from a query, something like this

page 1

1
2
3
4
5

page 2

6
7
8
9
10

page 3

etc

How would I do that? I can't use the id from the table, and I can't use $loop->iteration to print out a the index for each result, since loop->iteration would reset for each page load if I am correct?

How would I give index to all returned results and have it work accors all the pages

Upvotes: 1

Views: 96

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163768

You can use $loop->iteration and pagination instance methods:

($results->currentPage() - 1) * $results->perPage() + $loop->iteration

Upvotes: 1

Related Questions