Good afternon,

I am not seeing consistent results from my script below. 

It seems that sometimes it works and other times I get '0's in 
the quantity field.

As I don't write PERL often enough this is probably poorly written code!
Thanks for any help.

Dave  


HTML at:
<http://www.coraconnection.com/paul_s/pages/catalog.htm>

#!/usr/bin/perl -w

use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use strict;
my (@bags,@bag_quantity);
my ($bag_name,$imgName);
my (%bags_ordered,%prices);
my $n=0;
my $bags_ordered;
use Data::Dumper; 

# Build data structure 

@bags = param('handbag');  # get all of the bags styles
@bag_quantity = param('quantity');  # get all of the bags quantity 

foreach my $bag (@bags){
($bag_name,$imgName)  =  split (/,/,$bag);
$bags_ordered{$bag_name} = {} unless exists $bags_ordered{$bag_name}; # thanks rob!
$bags_ordered{$bag_name}->{image_name} =$imgName;
$bags_ordered{$bag_name}->{quantity} = $bag_quantity[$n]; 
$n++;
}

## I don't think '->' really needed

# will the order be correct, don think so!

#### Prices amounts with out '$' #####

%prices = (
'bag-style-dots' => 12,
'bag-style-dogs' =>5,
'bag-style-cats' =>44,
'bag-style-leather' =>15,
'bag-style-fur' =>23,
'bag-style-stripes' =>12,
'bag-style1' =>14,
'bag-style2' =>6,
'bag-style3' =>51,
);


#
#%bags_ordered = (
#"bag-style1" =>   { price => 10,
#               image_name => 'FIO-142b-small',
#                quantity=> 5
#              },
#
#"bag-style2" =>   { price => 12,
#               image_name => 'GUC-208-small',
#              quantity=> 5,
#              },
#
#);



print header;
# print HTML
print <<START_HTML;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd";>
<html lang="en">
<head>
<title>Catalog</title>
<style type="text/css" media="all">
<!--
 [EMAIL PROTECTED] "../paul_s/css/list.css"; 
-->
</style>
<style type="text/css" media="screen">
<!--
#catalog td {text-align:center; }
-->
</style>
<link rel="stylesheet" href="/paul_s/css/main.css" type="text/css">
</head>
<body bgcolor="white" text="black"> 
<img src="../paul_s/images/banner.jpg" alt=" tmp banner" width="720" height="76" 
border="1">
<h1 align="center">Complete your order</h1>
<p>more text on how complete your order......</p>
START_HTML

[EMAIL PROTECTED] = param();
#foreach my $name (@test){
#my $val = param($name);
#   print qq|<p>\$name $name \$val $val</p>\n|;
# }

print Dumper \%bags_ordered;

print "<hr noshade>\n";
 
  
print qq|<table border="1" width="600">\n<tr>\n|; 
print qq|<th colspan="2">Description</th><th>Quantity</th><th>Price</th>\n|; 
print  "</tr>\n"; 


foreach my $bag (keys %bags_ordered){
    print  "<tr>\n";
    print qq|<td><img src="../paul_s/images/| . $bags_ordered{$bag}{image_name} . 
qq|.jpg" alt="$imgName" width="120" height="179" alt=" bag "></td>\n|;
    print  "<td>$bag</td>";
    print  "<td>$bags_ordered{$bag}{quantity}</td><td>\$$prices{$bag}</td>\n";
    print "</tr>\n";
}

print "<tr><td>&nbsp;</td><td>subtotal</td>\n";
print "<tr><td>&nbsp;</td><td> fill in  </td>\n";

print "</table>\n";


#print <<ORDER_HTML;
#ORDER_HTML


# print end html tags  
print end_html;

# print start_form( -method => 'post' , -action =>"finnish-not done.pl");


exit;

==============================================
         Cora Connection: Your West African Music Source
              Resources, Recordings, Instruments & More!
                   <http://www.coraconnection.com/> 
==============================================

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to