This is the sql fiddle :http://sqlfiddle.com/#!2/e6acc/4
And it shows the right result since I want the duplicate entries to be enumerated.
But when I run in on mysql/phpmyadmin, the result is this:
1515 Abdominal
1100 Hep B Inj Fee
40 1-Ligation
40 1-Ligation
900 1-Suturing Fee
900 1-Suturing Fee
900 1-Suturing Fee
900 1-Suturing Fee
It’s all 1. I already restarted my pc. and its still the same. Why is that? I just retrieved the csv tables from my mysql to the fiddle.
edit:
Ok this is getting weirder. On my front-end, its working when I view other ID’s:

But still, when I change the id on my query and enter in on phpmyadmin, it stil shows 1.
I don’t have any idea why the SQL Fiddle is different than the actual result, but I managed to make it work for me in PHP. Use the following query:
The only thing I changed was line 27 from
JOIN (SELECT @curRow:=0) rtoJOIN (SELECT @curRow:=0, @prevRow:= '') r