source: subversion/sites/namefinder/www/queries.html @ 17445

Last change on this file since 17445 was 12163, checked in by david, 11 years ago

page to give table of recent queries

File size: 2.3 KB
Line 
1<?php
2
3/* User interface to name finder. search.xml is the programmatic
4   interface.  Note that while name finder itself does not require it,
5   ths file requires OpenLayers-2.4 to display the map
6   
7   This file also contains the javascript to iterpret name finder's 'where am I?'
8   query "places near lat,lon"
9*/
10
11include_once('preamble.php');
12include_once('querylog.php');
13
14/* Sessions are only used so that queries from the same user get logged in the same log file */
15session_start();
16
17if (! empty($_SERVER['REQUEST_URI'])) {
18  /* note what we were asked for */
19  $db->log("VISITING {$_SERVER['REQUEST_URI']}");
20}
21
22$start = ! empty($_GET['start']) ? $_GET['start'] : 0;
23$count = ! empty($_GET['count']) ? $_GET['count'] : 50;
24
25?>
26<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
27<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
28<head>
29<title>OpenStreetMap name finder sample quries</title>
30<meta name='description' content='OpenStreetMap name finder sample queries' />
31<meta name='MSSmartTagsPreventParsing' content='TRUE' /> 
32<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
33<style type='text/css'>
34body{
35  font-family: Verdana,sans-serif;
36  font-size: 0.8em;
37}
38table {
39  border: 0;
40}
41table td {
42  padding-right: 1em;
43}
44</style>
45
46<body>
47
48<h1>what have people been searching for?</h1>
49
50<p>note: people are searching for things all the time, so the list will change from page to page</p>
51
52<table>
53<thead><tr><td>date</td><td>search term</td></tr></thead>
54<tbody>
55<?php
56$q = $db->query();
57$ql = new querylog();
58$q->descending('id');
59$q->limit($count, $start);
60while ($q->select($ql) > 0) {
61  $date = date('Y-m-d H:i', $ql->date);
62  $terms = htmlspecialchars($ql->query, ENT_QUOTES, 'UTF-8');
63  $encodedterms = urlencode($ql->query);
64  echo "<tr><td>{$date}</td><td><a href='index.html?find={$encodedterms}'>{$terms}</a></td></tr>\n";
65}
66?>
67</tbody></table>
68
69<?php
70$later = $start - $count;
71$earlier = $start + $count;
72echo "<a href='?start={$earlier}&count={$count}'>earlier</a>\n";
73if ($start != 0) {
74  echo "<a href='?start={$later}&count={$count}'>later</a>\n";
75}
76echo "<a href='?start=0&count={$count}'>most recent</a>\n";
77?>
78</body>
79</html>
Note: See TracBrowser for help on using the repository browser.