Nicole <mailto:[EMAIL PROTECTED]>
    on Thursday, February 19, 2004 10:28 AM said:

> I have data that looks like this:

[snip]

> The second value is the year, I have have multiple files for the same
> year. What I want to do is output the values under Year sub headings.

ok woh. that's way too much code for me to wade through so i'll just
give you some ideas. hopefully you're not already implementing it.

1. you want to put your data in order (either ascending or descending)
but the year. and according to your short data snippet it looks like
you're already doing this. good job.

2. you need to somehow compare the date that's currently ready to be
printed with what was ALREADY printed. the way you do this is by having
a temporary variable that stores the previous year data. when the next
loop cycle occurs you can say "is this current date the same as the
previous cycles date?" and then act appropriately.

for (...)
{
        $current_date = $new_date;

        // if the current date does not equal the
        // old date you're obviously moving into
        // a new year and you should therefore
        // start a new group.
        if ($current_date != $old_date)
        {
                echo "<br/><br/>1915<br/>\n";
        }
        else
        {
                echo "&nbsp;&nbsp;(20, '1915', ...)<br/>\n";
        }

        $old_date = $current_date;
}

but of course instead of hard coding what gets printed you'd use your
variables to print the correct values.



hth,
chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to