Sök
Län Kommun
'; if(isset($_GET['search'])) { $query = (" SELECT CONCAT(county, municipality) AS code_municipality, county AS code, name FROM territory WHERE name LIKE '%$_GET[search]%' "); if($_GET[municipality] == 0) { $query .= 'AND municipality is NULL GROUP BY county ORDER BY name'; $type = 'Län'; } else { $query .= 'AND municipality is not NULL ORDER BY name'; $type = 'Kommun'; } $sql = mysql_query($query) or die(mysql_error()); echo ' '; if($_GET[municipality] == 1) { echo ''; } echo ' '; $i = 1; while($rows = mysql_fetch_array($sql)) { $bg = $bg != '#e1e1e1' ? '#e1e1e1' : '#ffffff'; echo ' '; if($_GET[municipality] == 1) { echo ''; } echo ' '; $i++; } echo '
 Kommun-kodLän-kod '.$type.'
'.$i.''.$rows['code_municipality'].''; if($_GET[municipality] == 1) { echo ''.$rows['code'].''; } else { echo $rows['code']; } echo ' '; if($_GET[municipality] == 0) { echo ''.$rows['name'].''; } else { echo $rows['name']; } echo '
'; } elseif(empty($_GET[countycode]) && empty($_GET['search'])) { $sql = mysql_query(" SELECT COUNT(municipality) AS municipality, county AS code, name FROM territory GROUP BY county ORDER BY name ") or die(mysql_error()); echo ' '; $i = 1; while($rows = mysql_fetch_array($sql)) { $bg = $bg != '#e1e1e1' ? '#e1e1e1' : '#ffffff'; echo ' '; $i++; } echo '
  Län-kod Län Antal kommuner
'.$i.' '.$rows['code'].' '.$rows['name'].' '.$rows['municipality'].'
'; } elseif(isset($_GET[countycode]) && empty($_GET['search'])) { $sql = mysql_query(" SELECT CONCAT(county, municipality) AS code, county, name FROM territory WHERE county = $_GET[countycode] AND municipality != $_GET[countycode] ORDER BY name ") or die(mysql_error()); $sql_county = mysql_query(" SELECT name FROM territory WHERE county = $_GET[countycode] AND municipality is NULL ORDER BY name ") or die(mysql_error()); $rows_county = mysql_fetch_array($sql_county); echo '

'.$rows_county['name'].'

'; echo ' '; $i = 1; while($rows = mysql_fetch_array($sql)) { $bg = $bg != '#e1e1e1' ? '#e1e1e1' : '#ffffff'; echo ' '; $i++; } echo '
  Kommun-kod Kommun
'.$i.' '.$rows['code'].' '.$rows['name'].'
'; } ?>