将HTML Option值与php变量进行比较

I've written this piece of code:

<select name="account_type" id="account" class="form-control" required>
    <option value="Asset">Asset</option>
    <option value="Bank">Bank</option>
    <option value="Capital">Capital</option>
    <option value="Cash" <?php if($_POST['Cash'] == $ledger_account){?> selected <?php }?>>Cash</option>
    <option value="Expense">Expense</option>
    <option value="Income">Income</option>
    <option value="Liability">Liability</option>
    <option value="Creditors">S. Creditors</option>
</select>

I got a value from different page, which is stored in $ledger_account. However, I want to see an option (for example, Cash) to be selected here when the page loaded if the option value matches with $ledger_account value. Please help me to identify what I've done wrong here.

Your code are correct. but it's give some error..

then try to somting like this...

 <option value="Cash" <?php if($_POST['Cash'] == $ledger_account){ ?> selected="selected" <?php }?> >Case</option>

I am not sure but i think this useful for you