in reply to Re: formatting output from a mysql query in column format
in thread formatting output from a mysql query in column format

It looks like you are missing a loop to iterate over all the COLUMNS returned from fetchrow_array.

I probably am -- how can I implement this within the code as it is?

Is there a reason you use the array slice syntax "@array$counter" to extract what appears to be a single item ?

Because the labels in the @array need to match up with the fields output by MySQL...also I am completely new to perl programming, so correct me if I am making some egregious error there (I don't count running perl scripts as experience).

  • Comment on Re^2: formatting output from a mysql query in column format

Replies are listed 'Best First'.
Re^3: formatting output from a mysql query in column format
by NetWallah (Canon) on Jul 27, 2011 at 05:07 UTC
    If I understand what you are trying to do - you are spinning your wheels too hard.

    Let the perl modules do the work for you.

    Here is what I think you are trying to get to:

    # @array contains the field names (You call them 'labels') . # OK - so I assume they are also the field names, and we will use the +m as labels. my $counter = 0; while ( my $r = $sth->fetchrow_hashref() ) { $counter ++; print " ---- $counter ------\n"; for my $fieldname (@array){ print " $fieldname:\t" . $r->{$fieldname} . "\n"; } }
    (Untested)

                "XML is like violence: if it doesn't solve your problem, use more."