Group Results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
charlielha
Forum Newbie
Posts: 5
Joined: Mon Jun 19, 2006 1:59 pm

Group Results

Post 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
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Search for: pagination.
charlielha
Forum Newbie
Posts: 5
Joined: Mon Jun 19, 2006 1:59 pm

Post 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
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Then add this to your query: LIMIT offset, row_count
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Group Results

Post 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.
charlielha
Forum Newbie
Posts: 5
Joined: Mon Jun 19, 2006 1:59 pm

Post 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?
Post Reply