脚本宝典收集整理的这篇文章主要介绍了php – 从select multiple中获取值并将它们输入到数据库中,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<select name="foo[]" multiple="multiple"> <option value="dog">Dog</option> <option value="cat">Cat</option> <option value="Fish">Fish</option> </select> <?PHP $PEts = $_POST['foo']; //sanITize and verify the input here. Escape PRoperly and what not $query = MysqL_query("INSERT INTO `pets` (`pet1`,`pet2`,`pet3`) VALUES ('".$pets[0]."','".$pets[1]."','".$pets[2]."')"); ?>
但说实话,这是建立数据库的一种可怕方式.做任何有意义的事情都会非常烦人或困难.
为什么不设置以下数据库:
用户:
id | name ---------- 1 | Tim
宠物:
id | user_id | type ------------------- 1 | 1 | Fish 2 | 1 | Cat 3 | 4 | Kakapo
以上是脚本宝典为你收集整理的php – 从select multiple中获取值并将它们输入到数据库中全部内容,希望文章能够帮你解决php – 从select multiple中获取值并将它们输入到数据库中所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。