| author | ymh <ymh.work@gmail.com> |
| Tue, 17 Jan 2012 00:19:27 +0100 | |
| changeset 112 | e7086d345a7c |
| parent 109 | 3371a40449c7 |
| permissions | -rw-r--r-- |
| 109 | 1 |
<?php |
2 |
include('connect.inc.php'); |
|
3 |
||
4 |
$q = (isset($_GET['term']) ? pg_escape_string($_GET['term']) : false); |
|
5 |
||
6 |
$sql = "SELECT label, COUNT(*) nb FROM hdabo_tag A, hdabo_taggedsheet B WHERE A.id=B.tag_id ".($q?"AND label ILIKE '%$q%' ":"")."GROUP BY label ORDER BY nb DESC LIMIT 20"; |
|
7 |
||
8 |
$rq = pg_query($sql); |
|
9 |
||
10 |
echo json_encode(pg_fetch_all($rq)); |
|
11 |
||
12 |
pg_free_result($rq); |
|
13 |
||
14 |
pg_close(); |
|
15 |
||
16 |
?> |