in reply to Re: No results from script
in thread No results from script

Hello.

I made a modification to the code to eliminate the push. The modification that I did make does bring me results but I'm not completely there.

Right now, my results appear as: if I have a customer with three tracking numbers, my table appears with a row of table headings and the first tracking number, then a second row with table headings and the second tracking number, and finally a third row of table headings and the third tracking number.

Is there a way to re-write my code to show the table headings once with the three tracking numbers underneath the headings?

Here's the modified code....
sub get_customer { my ($dbh, $track_ref, @track_ref) = @_; $dbh = WebDB::connect (); my $sth = $dbh->prepare ("SELECT * FROM Shipments WHERE customer_id = +?"); $sth->execute($customer_id); while (my @track_ref = $sth->fetchrow_array ()){ print table ({-border => 0}, Tr ({-align => "CENTER", -valign=>"TOP", -BGCOLOR=>"silver", -st +yle=>"font-family: verdana; font-size: 10pt;"}, th ({-width=>"50"},("Customer ID")), th ({-width=>"50"},("Carrier")), th ({-width=>"90"},("Tracking Number")) + )); print table ({-border => 0}, Tr ({-valign=>"center", -style=>"font-family: verdana; font-size: +10pt;"}, td ($track_ref[7]), td ($track_ref[3]), td ($track_ref[4]) )); } print start_form (-action => "http://wwwapps.ups.com/tracking/tracking +.cgi", -method => "POST"), table ( Tr ( td ("UPS Tracking Number:"), td (textfield (-name => "tracknum")) ), ), submit (-name => "choice", -value => "Track"), end_form (); }

Thanks for your help.

Replies are listed 'Best First'.
Re: Re: Re: No results from script
by naChoZ (Curate) on Jun 04, 2003 at 15:25 UTC
    Here, this is chopped up from something I did a long time ago.

    my $sql_statement = "SELECT * from foo where bar = \"$baz\" "; my $sth = $dbh->prepare($sql_statement); $sth->execute() or die "Can't execute SQL statement : $dbh->errstr"; $sth->bind_columns(undef, \$FOO,\$BAR,\$BAZ,\$ONE,\$FOR,\$EACH,\$COLUM +N); my $row; while ($row = $sth->fetchrow_arrayref) { my @fields = ( $row->[9],$row->[0],$row->[1],$row->[2],$row->[3], $row->[4],$row->[5],$row->[6],$row->[7],$row->[8] ); #i fooled with the order to make it print in the order i wanted &showrow(@fields); } $sth->finish; # this is where you tailor your output however you want sub showrow { print "<tr>\n"; # start your table row foreach $value (@_) { print $value; # this is where you do table data } print "</tr>\n"; # stop your table row }

    ~~
    naChoZ