I am trying to create a nested array, in order to produce a nested list within a webpage.
So far I have managed to get the following:
Array
(
[2012] => Array
(
[Show 1] => Array
(
[0] => Class 1
)
[Show 2] => Array
(
[0] => Class 1
)
)
[2009] => Array
(
[Show 1] => Array
(
[0] => Class 1
)
)
[2008] => Array
(
[Show 1] => Array
(
[0] => Class 1
)
)
)
However my actual results have more than 1 class per show, so it should look like:
[2012] => Array
(
[Show 1] => Array
(
[0] => Class 1
[1] => Class 2
[2] => Class 3
)
etc etc etc.
I've managed this far, but haven't a clue how to continue, in order to get more than one class per show.
My code is as follows:
$handlerresults = $db->query("SELECT SHOW_NAME, YEAR, CLASS_NAME FROM vwhandlerresults WHERE HANDLER_ID = $gethandlerid ORDER BY YEAR DESC");
$showname = '';
while($row = $handlerresults->fetch_array(MYSQLI_ASSOC)) {
$year = $row['YEAR'];
$show = $row['SHOW_NAME'];
$results[$year][$show] = array($row['CLASS_NAME']);
}
print_r($results);