How to make a select?

In the database field `active` is 1 or 0(int). How to make a select where you can choose 1 or 0, and the selected item was the current item, which is recorded in the database.
<label for="field102">Status</label>
 <select id="field102" name="active">
 <option value="<?= $data['active'] ?>" selected="selected"><?= ($data['active'] === 0) ? "Inactive" : "Active" ?></option>
 <option value="<?= ($data['active'] === 1) ? 0 : 1 ?>"><?= ($data['active'] === 1) ? "Active" : "inactive" ?></option>

But it's not working correctly. Or I tuplyu
July 9th 19 at 10:47
2 answers
July 9th 19 at 10:49
You certainly do pile up. All easier.
 <option value="0" <?="$data['active']" =="0" ? 'selected="true" ' : null;?>>Not active</option>
 <option value="1" <?="$data['active']" =="1" ? 'selected="true" ' : null;?>>Active</option>
July 9th 19 at 10:51
Conceptual question: why do a select, instead of the more obvious checkbox?

And usually have a select switch attribute selected and not distorted values. The same sequence order option is a bonus and not a bug.
<option value="1" <?="$data['active']" ? ' selected="selected" :"'?>>Active</option>
<option value="0" <?="!$data['active']" ? ' selected="selected" :"'?>>Not active</option>

Find more questions by tags HTMLPHP