【发布时间】:2014-07-31 19:56:31
【问题描述】:
我想编辑复选框值....我在 php 中创建了一个编辑页面。但是选定的值(从入口页面输入)没有显示并且无法更新值......那些输入的值不会被带到编辑页面,但是所有其他文本输入的值都会被相应地采用。
.......编辑页面>>
<tr>
<td align='center'>select gots-:</td>
<td>
<input type="checkbox" name="p_option[]" value="withcupon" <?php if(in_array($result->p_option=='withcupon','')) { ?> checked="checked"
<?php } ?>>with cupon
<br>
<input type="checkbox" name="p_option[]" value="withdiscount" <?php if(in_array($result->p_option=='withdiscount','')) { ?> checked="checked"
<?php } ?>>with discount
<br>
<input type="checkbox" name="p_option[]" value="aschannelpartner" <?php if(in_array($result->p_option=='aschannelpartner','')) { ?> checked="checked"
<?php } ?>>as channel partner
<br>
<input type="checkbox" name="p_option[]" value="freepasses" <?php if(in_array($result->p_option=='freepasses','')) { ?> checked="checked"
<?php } ?>>free passes
<br>
<input type="checkbox" name="p_option[]" value="vendorcontacts" <?php if(in_array($result->p_option=='vendorcontacts','')) { ?> checked="checked"
<?php } ?>>vendor contacts
<br>
<input type="checkbox" name="p_option[]" value="reatilersaddresses" <?php if(in_array($result->p_option=='reatilersaddresses','')) { ?> checked="checked"
<?php } ?>>reatilers addresses
<br>
</td>
</tr>
【问题讨论】:
-
我不得不用谷歌搜索,但你的 in_array 命令不正确,应该是 if(in_array('withcupon',$result->p_option))....
-
实际上是在 in_array 命令的第一个参数内进行比较,而不是在 in_array('what you looking for','in the array)
-
yap 该函数至少需要两个参数......但是我忘记在更新页面中定义提到的变量