require("header.php"); ?>
require_once("database.php"); ?>
$s = isset($_GET["search_string"]) ? $_GET["search_string"] : "";
$tok = strtok($s, " ");
$searchstring = "true";
while ($tok) {
//$searchstring .= " AND lower(value) ~ lower('" . mysql_real_escape_string($tok) . "')";
$searchstring = "lower(value) LIKE lower('%" . mysql_real_escape_string($tok) . "%')";
$tok = strtok(" ");
}
if (isset($_GET["search_string_year_after"]) and $_GET["search_string_year_after"]) {
$searchstring = "name_id=14 and CAST(lower(value) AS UNSIGNED) >= $_GET[search_string_year_after]" ;
}
if (isset($_GET["search_string_year_before"]) and $_GET["search_string_year_before"]) {
$searchstring = "name_id=14 and CAST(lower(value) AS UNSIGNED) <= $_GET[search_string_year_before]" ;
}
?>
// headers
$lang = intval(isset($_GET["lang"]) ? $_GET["lang"] : 0);
$list = 3;
if ($lang < 1 or $lang > 2) { $lang = 1; }
$sort_column = intval(isset($_GET["sort_column"]) ? $_GET["sort_column"] : 0);
$sort_direction = (intval(isset($_GET["sort_direction"]) ? $_GET["sort_direction"] : 1) != 0 ? "desc" : "asc");
$q = "select a.name_id, a.name, l.sortorder from lists l natural join defnames a where l.list_id=$list and (lang=$lang or lang is null) order by l.sortorder";
$res = mysql_query($q) or die($query. "
".mysql_error());
$colcnt = 0;
while ($row = mysql_fetch_row($res)) {
if ($sort_column == 0) {
$sort_column = $row[0];
}
$sort_column_col = $columns[$colcnt++] = $row[0];
$sort_direction_col = 0;
if ($sort_column == $sort_column_col) {
$sort_direction_col = (($sort_direction == "asc") ? 1 : 0);
}
?>
|
}
$ncolumns = $colcnt;
?>
$q="select valuecell.id, valuecell.value, sortcol.value, l.sortorder, l.name_id
from lists l left join fields valuecell on (l.name_id = valuecell.name_id and l.list_id=${list} and (valuecell.lang=${lang} or valuecell.lang is null))
left outer join fields sortcol on (sortcol.id = valuecell.id and sortcol.name_id = ${sort_column} and (sortcol.lang=${lang} or sortcol.lang is null))
where l.list_id = ${list} and (sortcol.name_id = ${sort_column} or sortcol.name_id is null)
and valuecell.id in (select distinct (id) from fields where ($searchstring) )
order by sortcol.value ${sort_direction}, valuecell.id, l.sortorder";
$res = mysql_query($q) or die($query. "
".mysql_error());
$curr = -1;
$rowcnt = 0;
$colcnt = 0;
while($row = mysql_fetch_row($res)) {
$id = $row[0];
$value = htmlspecialchars($row[1]);
$name_id = $row[4];
?>
while (($colcnt < $ncolumns) and ($columns[$colcnt] != $name_id)) {
?> |
$colcnt++;
}
if ($curr >= 0 && $curr != $id) {
echo "
\n";
$rowcnt++;
$colcnt = 0;
}
$colcnt++;
if ($curr != $id) {
?>|
|
} else {
?>
|
}
$curr = $id;
}
?>
require("footer.php"); ?>