I have included a sample database for this query with full create and insert commands. 2 tables, 2 rows on one table, 8 on another.
One table is periods, the other is period data, Using the following (kindly supplied on this site) MYSQL command I can successfully draw the latest 2 periods of data. 4 weeks in each. These are displayed as rows of data.. HOWEVER I want to generate these rows (using php or mysql.. or whatever it takes) so that the php page displays the data vertically to fit a table such as demonstrated in the image included.
The MYSQL statement I use to pull of the 2 period data is
FROM mfugi_kpi_perioddata period1
WHERE period1.periodnumber = ( SELECT MAX(id) FROM mfugi_kpi_period )
OR period1.periodnumber = ( SELECT MAX(id) FROM mfugi_kpi_period WHERE id < ( SELECT MAX(id) FROM mfugi_kpi_period ) )
ORDER BY period1.periodnumber DESC, weeknumber ASC
All advise / code appreciated.
The MYSQL is in a JOOMLA MODEL, and the display will be in a VIEW