在我的数据库表row()
中,我在'product_size'列中有“24,26,28,30”的大小。
查询后,我想在viewProduct.php页面中查看:
<'option value=" ">' size <'/option>`<br />
<'option value="24"> 24 <'/option>`<br />
<'option value="26"> 26 <'/option>`<br />
<'option value="28"> 28 <'/option>`<br />
<'option value="30"> 30 <'/option><br/>
与foreach()
循环一样。
答案 0 :(得分:0)
此代码是您所需要的:
<select name="product[location_id]">
<?php
foreach($product_locations as $product_location) :
echo "<option value=\"".$product_location['id']."\" ".($product_location['id'] == $product['product_location'] ? "selected=\"yes\"" : "").">".$product_location['title']."</option>";
endforeach;
?>
</select>
当然,您需要将其调整到您的表/列,因为您没有提供任何有关它的信息。
答案 1 :(得分:0)
使用爆炸方法;
$array=explode(",",$row['product_size']);
for($i=0;$i<count($array);$i++) {
echo $array[$i];
enter code here
}