作者beatada (爱睡喵)
看板PHP
标题Re: [请益] 商品"启用"或"关闭"(只能单一)!!
时间Fri May 20 16:51:58 2011
把id存在别的地方比较不会造成资源浪费
比方说把启用中商品 id 存放於档案或设定资料表中
然後读进 $configures['current_product'] 里
後台商品编辑表单的栏位
<input type="checkbox" name="current_product" id="current_product" value="1"
<?php if ($product['id'] === $configures['current_product']): ?>
checked="checked"
<?php endif; ?>
/>
<label for="current_product">设为目前商品</label>
後台商品更新程序
if (isset($_POST['current_product']) && $_POST['current_product'] === '1') {
if ($product['id'] !== $configures['current_product']) { // 勾选
$configures['current_product'] = $product['id'];
}
} else if ($product['id'] === $configures['current_product']) { // 取消勾选
$configures['current_product'] = '';
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.218.208.21
※ 编辑: beatada 来自: 61.218.208.21 (05/20 16:54)
※ 编辑: beatada 来自: 61.218.208.21 (05/20 16:55)