首页 > 解决方案 > 我如何使用“选定”属性在一个while循环中?<label for="brand_id">`选择品牌名称:` </label> <select name="filter[brand_id]"> <option value=""></option> <?php if(isset($_GET[ 'filter']['brand_id']) || (isset($_GET['filter']['category_id']))) {

问题描述

标签: phpwhile-loophtml-selectselected

解决方案


一个简单的例子就是这种情况:

<?php
$a = 1;
?>

<select>
    <option value='so and so' <?= ($a === 1) ? 'selected' : ''; ?>>
</select>

推荐阅读