This topic is locked

list latest date record for particular user

3/14/2011 6:39:52 AM
PHPRunner General questions
D
duck author

I thought this was simple- but!-i havn't solved it
i have a data set with 10 users each has several dated entries

I simply want 2 list views with the selected user (set within security setting) to show:-

a ) only the newest dated record for that userid

b ) only the prevoius dated record for that userid

I have tried a number of variations within the query sql tab and for example

1)max(date) doesnt work because other users have newer / older dated records

(edit :-)---group by fills in all the selected field and i didnt realize - you have to delete all the entries you don't need in the sql ie in the sql sheet add group by userid as last line and then the max(date)works!-I think the 'group by' button is as useful as a chocolate teapot!
3)limit 1 doesnt work- it appears to work- shows in result screen but when run build and display its not effective
its is simple i just cant see it

still looking for answer to b )!

Sergey Kornilov admin 3/14/2011

Here is the one of the ways how you can do that.

  1. In BeforeProcessList event add the following code:

$_SESSION["Rank"]=0;


This would be our record counter.
2. In List page: Before record processed event use the following code:
To display the first record only:

$_SESSION["Rank"]++;

return $_SESSION["Rank"]==1;


To display the second record only:

$_SESSION["Rank"]++;

return $_SESSION["Rank"]==2;