Welcome Guest, Not a member yet? Register   Sign In
Total n00b PHP loop question
#7

[eluser]Einspruch[/eluser]
Thanks! I am really close. I modified your code to the following:

Code:
<?php
    
    $last_topic = NULL;

    echo "<categories>\n";
    foreach($bfg_charts_midnightmysteries as $row)  {
        // If parent matches the previous parent, don't show it - just indent a bit
        echo "<category label='" . $row->Days . "'/>\n";
    }
    echo "</categories>\n";
    
    foreach($bfg_charts as $row)  {
        if ($row->Title == $last_topic)
            echo "";
        else
            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;
        }
?&gt;

This is 99% of what I need. The there is one last item. I need it to to close the "dataset" tag before it goes to the next title. In other words the current output (abbreviated):

Quote:<dataset seriesName='Midnight Mysteries: The Edgar Allan Poe Conspiracy'/>
<set unusedLabelDate='2009-07-19 unusedLabelDays='1' value=5/>
<set unusedLabelDate='2009-07-20 unusedLabelDays='2' value=5/>
....
<set unusedLabelDate='2009-11-29 unusedLabelDays='35' value=50/>
<dataset seriesName='Samantha Swift and the Golden Touch'/>
<set unusedLabelDate='2009-05-01 unusedLabelDays='1' value=6/>
<set unusedLabelDate='2009-05-02 unusedLabelDays='2' value=5/>

should look like this:

Quote:<dataset seriesName='Midnight Mysteries: The Edgar Allan Poe Conspiracy'/>
<set unusedLabelDate='2009-07-19 unusedLabelDays='1' value=5/>
<set unusedLabelDate='2009-07-20 unusedLabelDays='2' value=5/>
....
<set unusedLabelDate='2009-11-29 unusedLabelDays='35' value=50/>
</dataset>
<dataset seriesName='Samantha Swift and the Golden Touch'/>
<set unusedLabelDate='2009-05-01 unusedLabelDays='1' value=6/>
<set unusedLabelDate='2009-05-02 unusedLabelDays='2' value=5/>
</dataset>


Messages In This Thread
Total n00b PHP loop question - by El Forum - 11-28-2009, 05:26 PM
Total n00b PHP loop question - by El Forum - 11-28-2009, 05:59 PM
Total n00b PHP loop question - by El Forum - 11-28-2009, 06:44 PM
Total n00b PHP loop question - by El Forum - 11-29-2009, 01:10 AM
Total n00b PHP loop question - by El Forum - 11-29-2009, 03:13 AM
Total n00b PHP loop question - by El Forum - 11-29-2009, 05:35 AM
Total n00b PHP loop question - by El Forum - 11-29-2009, 05:59 PM
Total n00b PHP loop question - by El Forum - 11-29-2009, 06:49 PM
Total n00b PHP loop question - by El Forum - 11-30-2009, 04:07 PM
Total n00b PHP loop question - by El Forum - 11-30-2009, 04:32 PM
Total n00b PHP loop question - by El Forum - 11-30-2009, 06:44 PM
Total n00b PHP loop question - by El Forum - 11-30-2009, 07:00 PM
Total n00b PHP loop question - by El Forum - 12-17-2009, 03:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB