This topic is locked

Display Row Line Number (Master Or Detail Lists)

1/27/2013 7:51:06 PM
PHPRunner Tips and Tricks
F
FunkDaddy author

I have a Master form which displays multiple child items. I wanted to show "line numbers" for each of the child rows. Ex:1,2,3,4,5 etc
I found a nifty solution which worked well for me here: Jims Life Blog
Oh, and by the way... even my updateable table queries could remain updateable even after I added this extra select code to MySQL statement in PHPR!
Just to be safe I am including the basic text here in case his blog goes down:
COPY &PASTED TEXT:

========================================================

Sometimes you need to do query with MySQL for reporting.

And you'll need to display the row number/ranking in query result.
Example you have this table:
table : player

fields : playerid, name & score
For reporting purpose you need to query the top 10 (highest score).

The result should be : rank, memberid, name, score.

Example :

rank playerid name score

------------

1 A1029 Jimmy 100

2 A9830 Lia 98

3 B28d0 Lulu 90

...

...

10 B8789 Lele 50
Now you can easily query the top 10 by using 'limit' and 'order by', but how to automatically add row number in query result?
Here's how you do it:
select @rownum:=@rownum+1 'rank', p.* from player p, (SELECT @rownum:=0) r order by score desc limit 10;
Try it
This will create a variable rownum, initialize with value 0 & increase it by 1 for every record
=============================================
Cheers,

N
nikola.kecman 3/15/2019

Can you tel me how to show row numbers in PHPrunner version 9.8, but on report page ?