Categories > TinyButStrong general >

Stuck with kind of Matrix

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Lunatic
Date: 2009-01-13
Time: 17:51

Stuck with kind of Matrix

Good day, Im Stuck with a table dump from a Mysql Database. I having a hard time describing it, but try to do my best.

Here my 4 Tables with only the relevant Data

user-table
- UID Unique User ID
- Username

elective-table
- EID Unique ID of the Element
- CID Unique ID of the ParentCategory
- EName

category-table
- CID Unique ID of the Element
- CName

value-table
- UID Of The User
- EID Of The elective
- Points (Spend)

I tried to realize tables of this structure

                         CName (table block)

Username:                 EName (td block):     Elective00X...

Username 01(tr block)      (Points)               (Points)
Username 0X                   (Points)              (Points)
etc...

                         Cat 0X..

Username:         Elective012:     Elective00X...

Username 01      (Points)           (Points)
Username 0X      (Points)            (Points)
etc...

I tried it with a main block containing the Category Table and a sub block containing the electives, but then i am not able to fill my tables with the usernames in relation to the elective and the given Point.
Im getting clueless here, I even forgot how to write a appropiate mysql_query for that one.
could someone please help?
thanks.
By: Skrol29
Date: 2009-01-14
Time: 09:56

Re: Stuck with kind of Matrix

Hi Lunatic,

It seems that you want to display a cross table (dynamic number of columns) from a flat result.
In the in line example there is an example of dynamic columns, but you also need headers and cross data.

For crossing data, I usually arrange the data into a new Array at the PHP side before to merge them. That is the more simple.

After that point, you can perform a dynamic column merging using the same method as the example.

At the end, you add the header stuff.
By: Lunatic
Date: 2009-01-14
Time: 15:00

Re: Stuck with kind of Matrix

Got it working, big thanks!

Maybe I was too desperate on getting it to work yesterday, because I already experimented with the dynamic columns example, but you set me back on track.

Now I just have to implement some sorting functions and its perfect :)