0

I need to get a HTML Table in matrix form from this query:

SELECT category,
       entrydate,
       SUM(effortext+effortself)
FROM entries
WHERE YEAR(entrydate) = '2016'
GROUP BY category, month(entrydate)
ORDER BY category ASC

As Result I get something like:

category    entrydate   value
CAT1    2016-02-01  1051
CAT1    2016-03-01  903
CAT1    2016-04-01  869
CAT1    2016-05-02  546
CAT1    2016-06-01  486
CAT1    2016-07-01  530
CAT1    2016-08-01  604
CAT1    2016-09-01  639
CAT1    2016-10-04  879
CAT1    2016-11-01  1548
CAT1    2016-12-05  242
CAT2    2016-01-04  615
CAT2    2016-02-01  673
CAT2    2016-03-01  687
CAT2    2016-04-01  435
CAT2    2016-05-02  416

I need this data to be displayed as HTML Table using php, but I don't know how to start. For my database connection and queries I got procedural mysqli. Like mysqli_query()

category   Jan       Feb        Mar      Apr       May      Jun         Jul       Aug     Sep        Oct         Nov        Dec
CAT1        0          1051       903       869     546        ...
CAT2        ...
CAT3
...
4
  • 1
    Do this in your application code. SQL is not the suitable tool to perform this kind of manipulation Commented Mar 22, 2017 at 16:24
  • Thats the question: I just dont know how and where to start in php... For a normal table i would do a while loop or something else but this dont works for a matrix Commented Mar 22, 2017 at 16:53
  • stackoverflow.com/questions/10649419/pivot-tables-php-mysql Commented Mar 22, 2017 at 17:00
  • I'm sorry but the whole subselect examples dont work on Maria DB MySQL? Commented Mar 22, 2017 at 19:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.