0

How would you go about implementing an array design and function to achieve the following table in php. The data would be drawn from a mysql database but i would like to limit the number of mysql queries required and therefore use a formatted array of some sort.

-----------------------------------------
|           | 2009 | 2008 | 2007 | 2006 |
-----------------------------------------
| country a | d d  |      | doc  | doc  |
| country b |      | doc  | doc  |      |
| country c | doc  | d d  |      | doc  |
| country d | doc  |      | d d  |      |
-----------------------------------------

Where both d & doc are documents. And any date(y) / country can have many documents. The resulting table would be an html table.

2
  • are you storing the data as a triplet of (year, country, document) in mysql? Commented Dec 15, 2009 at 9:04
  • No, The Query consists of 3 tables via a JOIN, countries (iso,name),documents(id,country_iso,publication_date(datetime)),files(document_id,name) Could you suggest a mysql query and php function to print this to a table? Thanks Commented Dec 15, 2009 at 9:20

1 Answer 1

1

You should not be using arrays to manipulate or group data if you can help it. Try to get mySQL to do all the heavy lifting.

For example:

...GROUP BY YEAR(item_date)

Have a look at the Time Functions in mySQL.

Sign up to request clarification or add additional context in comments.

Comments

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.