Here is code without mysql
foreach ( $transaction_type as $i1=>$opt1 ) :
echo '<option value="' .htmlspecialchars($opt1) .'"' .(
(
htmlspecialchars($opt1) == htmlspecialchars($_POST['transaction_type'][$i])
)
? 'selected' : "" ) .'>'.htmlspecialchars($opt1) .'</option>';
endforeach;
Trying to modify. If in mysql certain field exists value, the value from mysql is the selected value. Else, echo the same as in code above.
Update
Here is code that at least for me is much more understandable. All works.
foreach ( $transaction_type as $i1=>$opt1 ) {
?>
<option value="<?php echo htmlspecialchars($opt1);?>"
<?php
if (
($opt1 == $_POST['transaction_type'][$i]) OR ($opt1 == $result[VatReturnTransactionType01])
}
{
echo 'selected';
}
?> >
<?php echo htmlspecialchars($opt1); ?>
</option>
<?php
}
?>