From 92ddda950c5bbbaf3dfcdc9ca41409ce248f43d5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 16 Aug 2009 16:34:10 +0100 Subject: [PATCH] Commodity listing, but query is wrong --- yarrg/web/query_commod | 55 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index 9cb14ca..a5c8846 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -37,6 +37,7 @@ $quri $dbh $commodstring => ''; +$prselector $someresults $emsgokorprint @@ -48,7 +49,9 @@ my ($commodname,$commodid); my $qa= \%ARGS; -

Select commodity

+

Select commodity enquiry

+ +% $prselector->('BuySell'); %#---------- textbox, user enters route as string ---------- % if (!$qa->{Dropdowns}) { @@ -77,10 +80,50 @@ Not yet implemented. %#========== results ========== -% $emsgokorprint->($emsg) or $commodid=undef; +<%perl> + +$emsgokorprint->($emsg) or $commodid=undef; +return unless defined $commodid; +$someresults->(); + +#---------- actually compute the results and print them ---------- + +foreach my $bs (split /_/, $ARGS{BuySell}) { + $bs =~ m/^(buy|sell)$/ or die; + $bs= $1; + + my $sth= $dbh->prepare( + "SELECT archipelago, islandname, stallname, price, qty + FROM $bs NATURAL JOIN stalls NATURAL JOIN islands + WHERE commodid = ?" + ); + # fixme this query is utterly wrong -% if (defined $commodid) { -% $someresults->(); -COMMODITY <% $commodid %> named <% $commodname |h %> + $sth->execute($commodid); -% } + + +

Offers to <% uc $bs |h %> <% $commodname |h %>

+ + + + +% my $row; +% while ($row=$sth->fetchrow_hashref) { + +% } +
Archipelago +Island +Best stall +Best price +Qty at best +
<% $row->{'archipelago'} %> + <% $row->{'islandname'} %> + <% $row->{'stallname'} %> + <% $row->{'price'} %> + <% $row->{'qty'} %> +
+ +<%perl> +} + -- 2.30.2