0

Hi,
I am a beginner, and would like to do something like:

I have a mysql table with date column. I would like to select all the rows from table, and print them out in tables. One table per month. E.g.

January:
...
...
...

February:
...
...
...

etc.

I don't want to manually select data for each month, rather dynamically generate the tables.

I am a beginner, but I am not looking for ready solution I want to code this myself, just don't know how to tackle this. I'd appreciate some suggestions and some examples if possible...

many thanks, g

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by pritaeas
0

If your query results are ordered by month and the order you want in your table, then you can do it in a single loop.

$current_month = 'none';
// ... get your query results
while ($row = mysql_fetch_assoc($result))
{
  if ($current_month <> $row['month'])
  {
    // End previous table, unless $current_month == 'none'
    $current_month = $row['month'];
    // Start new table
  }
  // Output your row
}
// Close the last table

Edited by pritaeas: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.