Position of Record from database when filtered with a query

Position of Record from database when filtered with a query.

I have a database with say 3 records in it. the IDs are 2, 24, 65 - because of the other records deleted.

So when i query the database and place it in a DATA VIEW repeat.
I can then use $index to get the position of the record.

But the problem with that is if I filter the query… say on the tel to value 1
Then the $index idea wont work … because the data is now filtered…
I have added manually the position of the record in field… just to give you an idea…

So when i query… the page… test.html?tel=1


Then it would filter the 2 records … to display them on the page… eg id 2 and 65… position 1 and 3 in the database…

and then the same with test.html?tel=2

So the question is… how would i be able to get the position of the record from a query… is that even possible or am i going about the wrong way of this…?

One way would be to run 2 queries in SC. One for all records and one for the filtered list. You could send the full one through a repeat to add a set value for index+1 (make sure it is set to output). Client side you could use the where formatted to find the record and it’s order value.

Seems like a lot of hassle. Is what you’re trying to achieve worth it?

1 Like

Hi Ben,… great let me see if i can do that… thanks for the suggestion… I know its seems like madness … but there is method behind the madness… its using timers… and increments and a few calculations for a final result hence the reason why i need the position on the page… but yes… strange request…