/
inc.routen.php
executable file
·67 lines (59 loc) · 1.89 KB
/
inc.routen.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/****************/
/* Routen */
/* routen.php */
/****************/
function get_routen($params=null) {
global $resturl;
$i = 0;
$arr = '';
$where = "";
// build WHERE phrase
if (isset($params["where"])) {
$where .= " WHERE 1 ";
foreach ($params["where"] as $key => $value) {
$where .= "AND ".$key."=\"".$value."\" ";
}
}
// build query-string and execute query
$query = "SELECT DISTINCT route FROM strassen".$where." ORDER BY route";
$result = mysql_query($query) or die ('Query failed: ' . mysql_error());
while ($line = mysql_fetch_assoc($result)) {
$arr["routen"][$i]["id"] = utf8_encode($line["route"]);
$arr["routen"][$i]["link"] = $resturl."routen/".utf8_encode($line["route"]);
$i++;
}
$arr["count_query"] = (int)$i;
mysql_free_result($result);
$query = "SELECT COUNT(DISTINCT route) FROM strassen".$where;
$result = mysql_query($query) or die ('Query failed: ' . mysql_error());
while ($line = mysql_fetch_assoc($result)) {
$arr["count_all"] = (int)$line["COUNT(DISTINCT route)"];
}
return $arr;
}
function get_route($id) {
global $resturl;
$arr = '';
$i = 0;
if ($id == "firma" || $id == "alle") {
$query = "SELECT strname,sid FROM strassen ORDER BY strname";
$result = mysql_query($query) or die ('Query failed: ' . mysql_error());
while ($line = mysql_fetch_assoc($result)) {
$arr["Strassen"][$i]["id"] = utf8_encode($line["sid"]);
$arr["Strassen"][$i]["link"] = $resturl."strassen/".utf8_encode($line["sid"]);
$i++;
}
} else {
$query = "SELECT strname,sid FROM strassen WHERE route = $id ORDER BY strname";
$result = mysql_query($query) or die ('Query failed: ' . mysql_error());
while ($line = mysql_fetch_assoc($result)) {
$arr["Strassen"][$i]["id"] = utf8_encode($line["sid"]);
$arr["Strassen"][$i]["link"] = $resturl."strassen/".utf8_encode($line["sid"]);
$i++;
}
}
$arr["count_all"] = $i;
return $arr;
}
?>