chiark / gitweb /
5378cf44637bf487f17b4118381b1695f59675cc
[ypp-sc-tools.db-live.git] / yarrg / web / pirates
1 <HTML>
2 <HEAD>
3 <TITLE>test pirate page</TITLE>
4 </HEAD>
5 <BODY>
6
7 <html><head><title>Select island</title></head><body>
8 <form action="/ucgi/~clareb/mason/something" method="get">
9 <select name="islandid">
10 <%perl>
11 my $sth=$dbh->prepare("SELECT islandid,archipelago,islandname
12                               FROM islands
13                               ORDER BY archipelago,islandname;");
14 $sth->execute();
15 </%perl>
16 % my $row;
17 % while ($row=$sth->fetchrow_hashref) {
18 <option value="<% $row->{'islandid'} |h %>"><% $row->{'archipelago'} |h %> -
19 <% $row->{'islandname'} |h %>
20 % }
21 <input type=submit name=submit value="Go">
22 </form>
23
24
25 use DBI;
26
27 our $dbh;
28 our $dbfn;
29 $dbfn= "/home/ijackson/things/ypp-sc-tools.pctb-dict-test/yarrg/OCEAN-Midnight.db";
30     $dbh=DBI->connect("dbi:SQLite:$dbfn",'','',
31                        { AutoCommit=>0,
32                          RaiseError=>1, ShowErrorStatement=>1,
33                          unicode=>1 })
34         or die "$dbfn $DBI::errstr ?";
35     # default timeout is 30s which is plenty
36
37 my $sth=$dbh->prepare(
38     "SELECT a.commodname,b.price,c.price,d.stallname,e.islandname
39      FROM commods as a
40      JOIN buy as b on a.commodid=b.commodid
41      JOIN buy as c on a.commodid=c.commodid
42      JOIN stalls as d on d.stallid=b.stallid
43      JOIN islands as e on e.islandid=d.islandid
44      WHERE a.commodname like 'Wood'
45      ");
46
47 $sth->execute();
48 </%perl>
49 <table frame=box rules=all>
50 <!--
51 <tr><td>Island</td><td>Arch</td><td>Stall</td><td>buy price</td><td>sell price</td></tr>
52 -->
53 % my @row;
54 % while (@row=$sth->fetchrow_array) {
55 <tr>
56 % foreach my $cell (@row) {
57 <td>
58 <% $cell %>
59 </td>
60 % }
61 </tr>
62 % }
63 </table>
64
65 </BODY>
66 </HTML>