1

I want to make a dynamic html table that would display data from my database. My database table looks like this:

 | name   | allowances | amount |
 |  jim   |   meal     |   900  |
 |  jim   |   fare     |   700  |
 |  alan  |   load     |   500  |
 | sohpie |   meal     |   900  |
 | sohpie |   load     |   500  |

I need my html table to display this:

 | name   | meal  | load | fare |
 |  jim   |  900  |   0  |  700 |
 |  alan  |   0   |  500 |   0  |
 | sohpie |  900  |  500 |  900 |

my problem is how i am going to output the amount as <td> aligned with the allowances as <th>.

Cœur
  • 37,241
  • 25
  • 195
  • 267
saitama
  • 13
  • 4
  • 2
    show your php code. @rizaldy cordero – Mayank Vadiya Jan 20 '16 at 07:04
  • i thought my code wasn't necessary because i am only new to php i was only able to retrieve the allowances as `` . i dont know know what to do about the amount. – saitama Jan 20 '16 at 07:26
  • I guess the easiest option would be to build a bidimentional array to store all the data the way you want, then just cycle the array as you build the table. – Andrea Jan 20 '16 at 07:35
  • Possible duplicate of [Get table column names in mysql?](http://stackoverflow.com/questions/1526688/get-table-column-names-in-mysql) – Mahmoud Tantawy Jan 20 '16 at 07:54

0 Answers0