[eluser]jedd[/eluser]
Oh, I didn't really take notice of the original code, sorry. I don't need that extra flag there - just use $last_topic for both purposes :
Code:
<?php
$last_topic = NULL;
echo "<categories>\n";
foreach($bfg_charts_midnightmysteries as $row)
echo "<category label='" . $row->Days . "'/>\n";
echo "</categories>\n";
foreach($bfg_charts as $row) {
// If parent matches the previous parent, don't show it - just indent a bit
if ($row->Title == $last_topic)
echo "";
else {
if ($last_topic)
echo "</dataset>\n";
echo "<dataset seriesName='" . $row->Title . "'/>\n";
}
// You're always showing the child information
echo "<set unusedLabelDate='" . $row->Date . " unusedLabelDays='" . $row->Days . "' value=" . $row->Rank . "/>\n";
// Set last topic to current topic (for test on next loop)
$last_topic = $row->Title;
}
echo "</dataset>\n";
?>
That should work the same way - untested code, of course.