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

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

Solid stuff, thanks !

No problem. If this answered your question, please mark it as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.