Thank you Mr. Anonymous Monk ;-)

The idea you had is surely great when being able to define the template structure used yourself. Unfortunatly, I'm forced to use what the Bugzilla Crew gives me to work with :-(
What I'm programming is an addon for my company for Bugzilla.

I've been able to modify the code so far, that the users are selected from the database and written into an array. the code looks like this:
--> in the external module, embedded in a sub: # Get user realnames for project my $sql = "SELECT DISTINCT realname FROM database.time_data WHERE vers +ion='$Version' AND product_id='$ProductID' AND milestone='$MileStone' +"; #user_id, my $sth = $dbh->prepare($sql); $sth->execute(); while(my @RowAdmin = $sth->fetchrow_array()) { push (@$AdminUsers, $RowAdmin[0]); } my $vars2 = { Users => [@$AdminUsers], Dates => [ { Day => 'day1', EndDates => [qw(dl1 dl2 dl3 dl4 dl5)], }, { Day => 'day2', EndDates => [qw(dl6 dl7 dl8 dl9 dl10)], }, { Day => 'day3', EndDates => [qw(dl11 dl12 dl13 dl14 dl15)], }, ], }; return($vars2); --> in the main script (buglist.cgi): # call subroutine my $vars2 = Admin(\@ReturnValues, \@AdminUsers); # pass results to template $vars->{'vars2'} = $vars2; --> in the template (table.html.tmpl): <table class=table> <tr class="[% loop.parity %]"> <td class=title_td colspan=6>Coordinator overview:</td> </tr> <tr class="[% loop.parity %]"> <td class=title_td>date</td> [% FOREACH realname IN vars2.Users %] [% FOREACH realname IN realname %] <td class=title_td>[% realname %]</td> [% END %] [% END %] </tr> [% FOREACH row IN vars2.Dates %] <tr class="[% loop.parity %]"> <td class=var_td>[% row.Day %]</td> [% FOREACH date IN row.EndDates %] <td class=var_td>[% date %]</td> [% END %] </tr> [% END %] </table>
Output: date user1 user2 user3 user4 user5 day1 dl1 dl2 dl3 dl4 dl5 day2 dl6 dl7 dl8 dl9 dl10 day3 dl11 dl12 dl13 dl14 dl15 What I don't quite see yet, is how I can get the days and the deadline part to be automated. I don't know how many days there are in the database and each day, a new dataset is added to the database and maybe there will be more than 5 users on a project at any time, so I have to somehow get the results I select from the database into the code you showed (wow, that rhymes). Embedding a while loop in the Dates=> part isn't possible, that was my first idea. So I would somehow have to rebuild the code, in order to automate the whole thing. I've only been programming in Perl for 4 weeks now so, to tell the truth, I'm a bit overstrained with the rebuilding needed here.
What would I need to do, to keep the output the same, but change the way it's processed beforehand to arrays or hashes?
Really sorry so being so helpless :-(

Regards

Fred

In reply to Re^5: How to skip certain values in a foreach loop by Anonymous Monk
in thread How to skip certain values in a foreach loop by Frederic_S

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.