如何从PHP中的数据库中获取复选框值以获取更新数据? [英] how to get checkbox value from database in php for update data?

查看:67
本文介绍了如何从PHP中的数据库中获取复选框值以获取更新数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

值存储为 A,B,C,D,E,F等。
现在我必须以更新的形式获取这些数据。
i必须检查复选框是否与数据库值匹配。

in database values are stored as "A,B,C,D,E,F" etc. now i have to fetch those data in the form for update. i have to check the checkbox if it matches the value with database value.

我正在执行这种代码(我知道这是错误的)

i am doing this kind of code(which i know is wrong)

    <input type="checkbox" name="time[]" value="free" <?php if(!strpos($row['best'], 'free')=="false") { echo "checked='checked'";} ?> />Free
    <input type="checkbox" name="time[]" value="Open" <?php if(!strpos($row['best'], 'Open')=="false") { echo "checked='checked'"; }?>/>Open Source
    <input type="checkbox" name="time[]" value="portable" <?php if(!strpos($row['best'], 'portable')=="false") { echo "checked='checked'"; }  ?> />Portable
    <input type="checkbox" name="time[]" value="support" <?php if(!strpos($row['best'], 'support')=="false") {
                        echo "checked='checked'"; }?> />Support


推荐答案

当strpos为0时(第一个字符),则如果您使用double =(==),则等于false。您需要使用=== false。除此之外,它应该是 false ,而不是 false

When strpos is 0 (first character), then it is equal to false if you use double = (==). You need to use ===false. Besides it should be false, not "false".

这篇关于如何从PHP中的数据库中获取复选框值以获取更新数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆