Jump to content

Archived

This topic is now archived and is closed to further replies.

kirk112

Displaying Values In Table

Recommended Posts

I have a query that selects:

id initals value
1  sk    13
2  sk    15
3  ge    13
4  hy    13
6  me    16
7  sk    14
8  hy    15

What I need to do is display the information in the following format, for the life of me I can not work how

SK  GE  HY  ME
13  13  13  16
13        15
13
13

52  13  18  16  Total

Thank you for your time.  Totally stumped! ???

Share this post


Link to post
Share on other sites
This sort of resembles an issue that I am having with my arrays...  I am working on figuring it out and when I do I'll post something here to help you -- unless someone does before hand...

Share this post


Link to post
Share on other sites
Radar

Just wondering if you manage to work out how to achieve this?  Been trying for the last couple of days and can't find a way of getting it to work properly.

Cheers


Share this post


Link to post
Share on other sites
Looks like a course exercise to me :)  I think that any way to do it will be messy.

I would do it like this:

1. Rearrange the data into an array using initials as the index, like:

array( 'sk' => array(13, 15, 14), 'ge' => 13);

2. Print out the header ("SK GE HY ME");

3. Print out the values, using an index variable to step through.  Ie, for ($i = 0; $i < $num_values; $i++) { print values in index $i for each initial }

That algorithm will work.  It's not elegant, but I can't think of any elegant way.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.