Welcome Guest, Not a member yet? Register   Sign In
crosstab and pagination
#1

[eluser]vtatds[/eluser]
i've built crosstabs before in sql server. however, i'm having difficulty getting one set up in mysql.
i'm trying to get dates as columns and people and their results for those dates as rows. something like this
01/01/2008 03/17/2009 04/01/2010
Bob 5:00 Mins 4:45 Mins 4:00 Mins
Sally 8:00 Mins 7:38 Mins 6:37 Mins
Ted 3:00 Mins
Jane 5:00 Mins 4:26 Mins

I'm currently running two queries; one to get the dates for the columns and one to get the results for those dates. then looping through the arrays returned from the query for dates to make the column headers and then the results array, comparing dates in both arrays to determine if i print a result or space. the display isn't as tight as i'd like but i've made it work.

however, i can't seem to get pagination to work with this(two arrays of different lengths). i'm a little rusty with my logic these days. anyone have any thoughts on doing a proper crosstab this using mysql (dates and results come from a database so I can't hardcode IF in the query). all the examples I've seen with mysql hardcode the columns and they are doing SUM in the rows. i'm having a hard time getting past that and applying the logic to my data.
#2

[eluser]jmadsen[/eluser]
Which par tof the pagination are you having trouble with - the usual rows going on to the next page, or are you trying to move horizontally to a next set of dates? (Or both?)

The way the CI Pagination lib works, you basically rerun the query with a different offset, always with a limit of however many items you want on the page at once. You will also need to get Counts to know how many pages to display in the "menu bar" (i.e., "Previous 2 3 4 Next" links)

Does that get you started, or is it the sql?
#3

[eluser]vtatds[/eluser]
moving horizontally to next set of dates. so i want 5 dates per page, but results for everyone for those 5 dates.




Theme © iAndrew 2016 - Forum software by © MyBB