This is my php code.
$list .="<option value='$A $B'> $A,$B </option>";
I want to put a select option based on data. for example if $A = 1 and $B =2 then the option value get selected.
Normaly I would do it through this code
<?php echo $A == '1' ? 'selected' : ''; ?>
but since the $list is already in php quotes I cant.
Option 1:
$list .="<option value='$A $B' ". ($A == '1' ? 'selected : '') ."> $A,$B </option>";
Option 2:
$selected = $A == '1' ? 'selected : '';
$list .="<option value='$A $B' $selected> $A,$B </option>";
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments