From: Ian Jackson Date: Sun, 16 Aug 2009 15:34:10 +0000 (+0100) Subject: Commodity listing, but query is wrong X-Git-Tag: 3.4~171 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=92ddda950c5bbbaf3dfcdc9ca41409ce248f43d5 Commodity listing, but query is wrong --- 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> +} +