I have a website that shows users data based on the State they live in. There is a filter via a drop-down list that allows them to select any State or all States. The current default selection is to show them the data from THEIR State.
I want to change the default to show all States (no filter). There is a list item at the top called "Alle" that does this, but I don't know how to make this the default when the webpage loads.
Here's the current code:
<label class="control-label" for="Bundesland">Bundesland:</label>
<div class="controls">
<select class="span12" id="Bundesland" name="filter[bundesland]">
<option value="">Alle</option>
<?php
$a = [
'01' => 'Schleswig-Holstein',
'02' => 'Hamburg',
'03' => 'Niedersachsen',
'04' => 'Bremen',
'05' => 'Nordrhein-Westfalen',
'06' => 'Hessen',
'07' => 'Rheinland-Pfalz',
'08' => 'Baden-Württemberg',
'09' => 'Bayern',
'10' => 'Saarland',
'11' => 'Berlin',
'12' => 'Brandenburg',
'13' => 'Mecklenburg-Vorpommern',
'14' => 'Sachsen',
'15' => 'Sachsen-Anhalt',
'16' => 'Thüringen',
];
asort($a);
?>
<?php foreach ($a as $code=>$name): ?>
<option value="<?=$code?>" <?=$code == $this->filter['bundesland'] ? 'selected' : ''?>><?=$name?></option>
<?php endforeach ?>
</select>
Screenshot of drop-down list: