使用爆破功能读取复选框值 [英] Reading checkbox values using implode function
本文介绍了使用爆破功能读取复选框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在此表单中插入了多个复选框项目,这些项目收集了一些值,我需要做的是将此值作为由逗号分隔的字符串进行回显,但是我在implode函数中遇到错误,它表示传递了无效的参数
I have inserted this form with multiple checkbox items which collects some values, What i need to do is echo this values as a string separated by a comma, but i'm getting error in the implode function, it says Invalid arguments passed.
您能看到代码吗?
if(isset($_POST['Submit'])) {
echo "<pre>"; print_r($_POST);
$checked = mysql_real_escape_string(implode(',', $_POST['checkbox']));
echo $checked;
}
?>
HTML表单
<form action="checkbox.php" method="post">
<input type="checkbox" name="checkbox[]" value="hostess_name">
<input type="checkbox" name="checkbox[]" value="hostess_familyname_en">
<input type="checkbox" name="checkbox[]" value="hostess_id">
<input type="checkbox" name="checkbox[]" value="hostess_firstname_en">
<br>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
推荐答案
尝试一下
if(isset($_POST['Submit'])) {
echo "<pre>"; print_r($_POST);
$checked = implode(',', $_POST['checkbox']);
echo $checked;
}
这是我放入test.php
<?php
if(isset($_POST['Submit'])) {
echo "<pre>";
$checked = implode(',', $_POST['checkbox']);
echo $checked;
}
?>
<form action="test.php" method="post">
<input type="checkbox" name="checkbox[]" value="hostess_name">
<input type="checkbox" name="checkbox[]" value="hostess_familyname_en">
<input type="checkbox" name="checkbox[]" value="hostess_id">
<input type="checkbox" name="checkbox[]" value="hostess_firstname_en">
<br>
<br>
<input type="submit" name="Submit" value="Submit">
</form>
这篇关于使用爆破功能读取复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文