What's the best method to output multiple "selected" for my form select based on the URL parameter?
In my URL I might have these parameters &carBrand=1607191|Acura&carbrand=1607185|Alpha Romeo
But when I submit the URL the only option selected is the second one. And for this form I need to have multiple car selections selected via the url.
<?php $carBrand = !empty( $_GET['carBrand'] ) ? $_GET['carBrand'] : ''; ?>
<select name="brands[]" id="selectBrands" class="form-control" multiple="multiple">
<option value="1607191|Acura" <?php echo $carBrand == '1607191|Acura' ? 'selected' : ''; ?>>Acura</option>
<option value="1607185|Alpha Romeo" <?php echo $carBrand == '1607185|Alpha Romeo' ? 'selected' : ''; ?>>Alpha Romeo</option>
<option value="1607197|Aston Martin" <?php echo $carBrand == '1607197|Aston Martin' ? 'selected' : ''; ?>>Aston Martin</option>
<option value="1607188|Audi" <?php echo $carBrand == '1607188|Audi' ? 'selected' : ''; ?>>Audi</option>
<option value="1607200|BMW" <?php echo $carBrand == '1607200|BMW' ? 'selected' : ''; ?>>BMW</option>
<option value="1607194|Bentley" <?php echo $carBrand == '1607194|Bentley' ? 'selected' : ''; ?>>Bentley</option>
<option value="1607203|Bugatti" <?php echo $carBrand == '1607203|Bugatti' ? 'selected' : ''; ?>>Bugatti</option>
<option value="1607206|Buick" <?php echo $carBrand == '1607206|Buick' ? 'selected' : ''; ?>>Buick</option>
</select>