我的刀锋上有这个:
<select class="form-control" id="item_type" name="item_type">
<option value="physical-goods" <?php if ($product->item_type="physical-goods") echo 'selected=" selected"'; ?>>Physical Goods</option>
<option value="digital-downloads" <?php if ($product->item_type="digital-downloads") echo 'selected=" selected"'; ?>>Digital Downloads</option>
<option value="credits" <?php if ($product->item_type="credits") echo 'selected=" selected"'; ?>>Credits</option>
</select>这就是它看起来的样子

即使样本产品是实物商品,它也应该是

我的代码出了什么问题?
发布于 2018-09-04 17:27:40
使用双精度等于单个==的instaed
<?php if ($product->item_type`enter code here`=="digital-downloads") echo 'selected=" selected"'; ?>
<select class="form-control" id="item_type" name="item_type">
<option value="physical-goods" <?php if ($product->item_type=="physical-goods") echo 'selected=" selected"'; ?>>Physical Goods</option>
<option value="digital-downloads" <?php if ($product->item_type=="digital-downloads") echo 'selected=" selected"'; ?>>Digital Downloads</option>
<option value="credits" <?php if ($product->item_type=="credits") echo 'selected=" selected"'; ?>>Credits</option>
</select>https://stackoverflow.com/questions/52162968
复制相似问题