计算机网络/计算机科学与应用/系统/运维/开发

ThinkPHP5.1 取得checkbox复选框值

效果:

image.png


添加:

html

<input type="checkbox" name="recommend[]" value="王套餐页推荐师" />

<input type="checkbox" name="recommend[]" value="首页案例推荐"/>

<input type="checkbox" name="recommend[]" value="案例列表页推荐"/>


后台:

ThinkPHP5 不能提交数组,否则变为空

   // 强制转为数组

   $recommends = input('post.recommend/a');

   // 将数组转换为字符串

   $data['recommend'] = implode(",",$recommends) ;


注意:

s强制转换为字符串类型

d强制转换为整型类型

b强制转换为布尔类型

a强制转换为数组类型

f强制转换为浮点类型


查询:

->where('find_in_set(1,recommend)')


参考:

https://blog.csdn.net/Interesting_wang/article/details/79845226

https://blog.csdn.net/haibo0668/article/details/78125044

https://blog.csdn.net/haibo0668/article/details/78126768

https://www.cnblogs.com/lhm166/articles/11641526.html

https://www.cnblogs.com/twilight-sparkle/p/10315346.html

thinkphp

读书和赚钱都是一个人最好的修行,前者使人不惑,后者使人不屈,二者结合,便可不困于世,不流于俗

评论

^