What is the correct syntax for using an "if" statement in PHP to select a specific option in a dropdown list?

When using an "if" statement in PHP to select a specific option in a dropdown list, you need to check each option and add the "selected" attribute to the option that you want to be selected. You can achieve this by using a conditional statement to determine which option should be selected based on a certain condition.

<select name="dropdown">
    <option value="option1" <?php if($condition == 'option1') { echo 'selected'; } ?>>Option 1</option>
    <option value="option2" <?php if($condition == 'option2') { echo 'selected'; } ?>>Option 2</option>
    <option value="option3" <?php if($condition == 'option3') { echo 'selected'; } ?>>Option 3</option>
</select>