PDA

View Full Version : trouble retrieving hash data from table


bazz
08-05-2008, 11:03 PM
Hi,

I am trying to get data from a table where more than one record relates to a category and I need each of the field values, like this


0000000001 0000000015 Pillows Goose Down Pillow 1 0 001 1
0000000002 0000000015 Pillows Hollow-Fibre Pillow 1 0 001 1
0000000003 0000000015 Pillows Non-Allergenic Pillow 1 0 001 1
0000000004 0000000015 Flowers Posey 1 35 001 0
0000000005 0000000015 Flowers bouquet 1 45 001 0
0000000006 0000000015 Flowers Bunch 1 55 001 0



This is my query and I can't work out whether this is the correct query for this.


while ( $option = $sth->fetchrow_hashref)
{
my $option_category = $option->{option_category};
my $option_name = $option->{option_name};
my $option_cost = $option->{option_cost};
my $additional_detail = $option->{additional_detail};
my $guest_specific = $option->{additional_detail};
my $notes = $option->{notes};
my $currency = $option->{currency};
my $option_data = $option->{option_data};
my @option_data = (split /,/, $option_data);



you see, I need to display the option_category once and each of several option_items.

should I be using the hashref query or, an array and then build a hash?

bazz

oesxyl
08-05-2008, 11:12 PM
should I be using the hashref query or, an array and then build a hash?
hi,

in my opinion, fetching as array and build a hash add a useless
step.

regards

bazz
08-05-2008, 11:57 PM
Thanks oesxyl,

Your help has enabled me to get it worked out now. :)

bazz

oesxyl
08-06-2008, 12:12 AM
Thanks oesxyl,

Your help has enabled me to get it worked out now. :)

bazz
:), I'm glad, :)

best regards