id | num | text
1 | a | sdfsdf
2 | a | sdfsdf
3 | b | sdfsdf
4 | c | sdfsdf
5 | a | sdfsdf
6 | b | sdfsdf
7 | a | sdfsdf
8 | c | sdfsdf
i make query where num = a and orderBy ID DESC and i have:
id | num | text
7 | a | sdfsdf
5 | a | sdfsdf
2 | a | sdfsdf
1 | a | sdfsdf
i would like add for this own counter:
count | id | num | text
4 | 7 | a | sdfsdf
3 | 5 | a | sdfsdf
2 | 2 | a | sdfsdf
1 | 1 | a | sdfsdf
i get data with foreach PHP:
foreach ($data as $i => $dat) {
echo $dat->id . $dat->num . $dat->text;
}
i would like somethings:
foreach ($data as $i => $dat) {
echo $i . $dat->id . $dat->num . $dat->text;
}
but $i in the opposite direction
You can do this: