Retaining values in drop down menu, check box, radio button

When validating a form, to retain the initially filled value in
a text box after the submit button has been clicked, we use
value=“<?php echo $value ;?>” in the text box
tag, how do we retain the values selected in a drop down menu,
check box, radio button?

Thanks.

Don’t know if there’s a better way, but this is how I do it:

Radio button:

<input id="whatever" name="test" type="radio" value="Test" <?php if (isset($_POST["test"])) {echo 'checked="checked"';} ?>>

Check box

<input type="checkbox" id="whatever" name="test" value="Test" <?php if (isset($_POST["test"])) {echo 'checked="checked"';} ?>>

Drop list

<select id="whatever" name="currency">
<option value="no choice"><?php if (isset($_POST['currency'])) {print "$currency";} else {print 'Choose a Currency!';}?></option>
<option value="USD">USD</option>
<option value="Sterling">Sterling</option>
<option value="CAD">CAD</option>
<option value="Rupees">Rupees</option>
</select>