<?php if (file_exists('../include/collections_functions.php')) { $relpath = '..'; } else { $relpath = '../..'; } include_once "{$relpath}/include/db.php"; include_once "{$relpath}/include/general.php"; include_once "{$relpath}/include/authenticate.php"; include_once "{$relpath}/include/collections_functions.php"; $max_theme_levels = get_max_theme_levels(); // max number of theme columns currently in table function getThemeList($parents = array()) { if (count($parents) == 0) { // just retrieve all the top level themes $sql = "select distinct theme as value from collection where theme is not null and theme <> '' order by theme"; } else { // we were passed an array of parents, so we need to narrow our search for ($i = 1; $i < count($parents) + 1; $i++) { if ($i == 1) { $searchfield = 'theme'; } else { $searchfield = "theme{$i}"; } $whereclause = "{$searchfield} = '" . escape_check($parents[$i - 1]) . "' "; } $sql = "select distinct theme{$i} as value from collection where {$whereclause} and theme{$i} is not null and theme{$i} <> '' order by theme{$i}"; //echo $sql; }
<?php if (file_exists('../include/collections_functions.php')){ $relpath = '..'; } else { $relpath = '../..'; } include_once "$relpath/include/db.php"; include_once "$relpath/include/authenticate.php"; include_once "$relpath/include/general.php"; include_once "$relpath/include/collections_functions.php"; $max_theme_levels = get_max_theme_levels(); // max number of theme columns currently in table function getThemeList($parents=array()){ if (count($parents) == 0){ // just retrieve all the top level themes $sql = "select distinct theme as value from collection where theme is not null and theme <> '' order by theme"; } else { // we were passed an array of parents, so we need to narrow our search for ($i = 1; $i < count($parents)+1; $i++){ if ($i == 1){ $searchfield = 'theme'; } else { $searchfield = "theme$i"; } $whereclause = "$searchfield = '" . escape_check($parents[$i-1]) . "' "; } $sql = "select distinct theme$i as value from collection where $whereclause and theme$i is not null and theme$i <> '' order by theme$i";