Page 1 of 1

Group Results

Posted: Mon Jun 26, 2006 2:51 pm
by charlielha
Hi,

I have a table that when queried will come up with results like:

1, 2, 3, 4, 5, 6, 10, 11, 12, 13, 22, 23, 24, 25, 30, 35, 40, 41, 42, 43 etc

What I want to do is display the results like this:

1 - 6, 10 - 13, 22 - 25, 30, 35, 41 - 43

and then have the user click on lets say 1 - 6 and have another page display the 1, 2, 3, 4, 5

any help??


thanks

Posted: Mon Jun 26, 2006 2:54 pm
by Oren
Search for: pagination.

Posted: Mon Jun 26, 2006 2:59 pm
by charlielha
BTW, this are not page numbers. This are actual results. The numbers are ids:

001,002, 003 etc

I used 1, 2, 3 to make it easier

Posted: Mon Jun 26, 2006 3:07 pm
by Oren
Then add this to your query: LIMIT offset, row_count

Re: Group Results

Posted: Mon Jun 26, 2006 3:13 pm
by RobertGonzalez
charlielha wrote:Hi,

I have a table that when queried will come up with results like:

1, 2, 3, 4, 5, 6, 10, 11, 12, 13, 22, 23, 24, 25, 30, 35, 40, 41, 42, 43 etc

What I want to do is display the results like this:

1 - 6, 10 - 13, 22 - 25, 30, 35, 41 - 43

and then have the user click on lets say 1 - 6 and have another page display the 1, 2, 3, 4, 5

any help??


thanks
These are some terribly odd ranges. I am not sure there is logic appropriate to produce ranged data sets like this. You can do it in code, but again, with this add of a logic for your ranges, you may be up against quite a bit of programming.

Posted: Tue Jun 27, 2006 8:36 am
by charlielha
Oren wrote:Then add this to your query: LIMIT offset, row_count
How would my query look and what results would i get?

Could I do it by creating arrays?? Basically having an array get reocrds till is sees a result that is not sequential, then the code will create a new array.

So I would have an array for each group of records.

Could I hold this arrays on another main array?