0
Hello, I’m doing a donor ranking, but I had a little problem I am wanting to list all users and want to organize by increasing numbers, ex: 1,2,3,4,5,6..
but when I go to the next page the numbers keep
S: I cannot list by ID (ORDER BY id ASC), pos if it is a ranking, the query below is only to explain
I did something like, but without success
$total_pages = $api->query('SELECT * FROM doadores')->numRows();
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1;
$num_results_on_page = 5;
$calc_page = ($page - 1) * $num_results_on_page;
if ($stmt = $api->query('SELECT * FROM doadores LIMIT ?,?', $calc_page, $num_results_on_page)->fetchAll()) {
$num = 0;
foreach ($stmt as $row){ ?>
<tr>
<td><?php echo $num++; ?></td>
<td><?php echo $row['nome']; ?></td>
</tr>
...
PREV 1 2 3 4 ... 120 NEXT
It’s not enough to do
($page - 1)*$num_results_on_page + $num++
instead of just$num++
?– Woss
@Woss in general would look the same '-'
– javinha
Why do you say that?
– Woss
@Woss $num = 1; $calc_page = ($page - 1) * $num_results_on_page + $num++; = always returns 2
– javinha
That’s not
$calc_page
, but yes yourecho
inside the table– Woss
worked perfectly, thank you. could answer the question for me mark your answer?
– javinha