Emerson F
Emerson F

Reputation: 845

Sorting data according to data header

In wordpress, this is how my table is currently like coded in HTML and grabbed from the database:

Name  | Payments
Stud1 | 1-Jan, 1-Feb, 1-Mar
Stud2 | 1-Feb, 1-Mar
Stud3 | 1-Jan, 1-Feb, 1-Mar, 1-Apr'13, 1-May
Stud4 | 1-Apr, 1-May, 1-Jun

This is hard to see, since the data are all jumbled up. I need to display it this way:

Name  |  Jan'13  |  Feb'13  |  Mar'13  |  Apr'13  |  May'13  |  Jun'13  |
Stud1 |  1-Jan   |  1-Feb   |  1-Mar   |    nil   |    nil   |   nil    |
Stud2 |   nil    |  1-Feb   |  1-Mar   |    nil   |    nil   |   nil    |
Stud3 |  1-Jan   |  1-Feb   |  1-Mar   |  1-Apr   |   1-May  |   nil    |
Stud4 |    nil   |    nil   |    nil   |  1-Apr   |   1-May  |   1-Jun  |

Just for some information, the database stores only the date which has data. Nil is displayed when no data exists.

After looking around, I don't know what techniques is available for such listing. Would appreciate if someone points me somewhere.

My script is in php, and I do not mind implementing jQuery if required.

I'm looking at Flexigrid and SlickGrid, but I'm not sure if that actually is helping what I need.

Upvotes: 0

Views: 58

Answers (1)

Moeed Farooqui
Moeed Farooqui

Reputation: 3622

In this case your table schemea is wrong.You need to create another table like Payments where you will insert the payments relevant to Student ID.

Student_ID  | Payments
1           | 1-Jan, 1-Feb, 1-Mar
1           | 1-Feb, 1-Mar

and so on..

Upvotes: 1

Related Questions