in reply to Re: Counting fields from database
in thread Counting fields from database

Thanks! Your example with the hash works but I still have to hit the database twice. Once to get the total threadcount and then again to print the content. I wasn't able to get it to work in one loop, but that's okay it works. Thanks.

Replies are listed 'Best First'.
Re^3: Counting fields from database
by BillKSmith (Monsignor) on Oct 03, 2020 at 18:29 UTC
    Clearly you cannot print any counts until after you have read all the data at least once. As you read the DB, compute the counts and store all data (including counts) in a convenient data structure. Pass that structure to a subroutine which formats and prints it any way you like. Any data structure that saves all the data will 'work', but a well designed structure will greatly reduce the amount of code you must write. You have not told us enough about your data or your print requirements for us to offer much help.
    Bill