1 <?php $title = "Game Archive"; include("header.phtml"); ?>
3 <div id="text-content">
9 <li><a href="/tourney">Recent Tournament Games</a></li>
10 <li class="active"><a href="/games">Game Archive</a></li>
14 <form id="games-search" action="games">
17 <input name="q" value="<?=htmlentities(stripslashes($_GET['q']))?>">
18 <input type="submit" value="Go">
24 function show_results($query) {
25 $query = preg_replace("/[^a-zA-Z0-9 -]/", "", $query);
26 $db = sqlite3_open("kombilo/t1.db");
27 $res = sqlite3_query($db, "select * from games
28 where pb like '%$query%' or pw like '%$query%' or ev like '%$query%' or date like '%$query%'
32 while ($game = sqlite3_fetch_array($res)) $games[] = $game;
34 echo "<p>No games found matching "$query".</p>";
37 echo "<p>" . count($games) . " games found, newest listed first:</p>
38 <table id='tourney-games'>
39 <tr><th>Date</th><th>Event</th><th>White</th><th>Black</th><th>Result</th></tr>";
41 foreach ($games as $game) {
42 $class = $class == "odd" ? "even" : "odd";
43 $gn = str_replace(".sgf", "", $game['filename']);
44 echo "<tr class='$class'>\n";
45 echo join("", array_map(create_function('$s', 'return "<td><a href=\"./#' . $gn . '\">" . $s . "</a></td>\n";'),
46 array($game['date'], $game['EV'], $game['PW'], $game['PB'], $game['RE'])));
52 show_results($_GET['q']);
54 echo "<p>The game archive contains a representative sample of games from the last few hundred years.
55 Enter a query above to search by player name, event name, or date.</p>";
63 <?php include("footer.phtml"); ?>