[英]checkbox value not get -> Notice: Undefined index: name1 in C:\wamp\www\crud_exer1\content.php on line 27
I'm trying to do multiple deletion with checkboxes.. But as a test, I tried to get the values of the first two checkboxes but it's not working.. I did: 我正在尝试使用复选框进行多次删除。。但是,作为测试,我尝试获取前两个复选框的值,但是它不起作用。
<td> <input type="checkbox" name=" <?php echo $name[$pos]; ?> " value="<?php echo $row["id"]; ?>" /> </td>
to display records first when the page loads then at the top, I did the following to print the name of the first 2 checkboxes as well as print the value of the 1st checkbox: 为了在页面加载时首先显示记录,然后在页面顶部显示,我执行了以下操作以打印前两个复选框的名称以及第一个复选框的值:
elseif(isset($_POST["delete"])){
echo $name[0];
echo $name[1];
$value_of_box = $_POST["$name[0]"];
echo $value_of_box;
}
but only the name of the checkboxes are recognized since it prints 但仅复选框的名称可以识别,因为它可以打印
name1name2
名称1名称2
but I'm getting this error: " 但我收到此错误:
Notice: Undefined index: name1 in C:\\wamp\\www\\crud_exer1\\content.php on line 27
注意:第27行的C:\\ wamp \\ www \\ crud_exer1 \\ content.php中的未定义索引:name1
" when it comes to printing the value of the checkbox.. I thought that if it recognized the name of the box, it should also recognized the value, right? WHAT'S WRONG WITH THIS? “当涉及到打印复选框的值时。我以为,如果它识别了复选框的名称,那么它也应该识别该值,对吗?这是什么地方错了?
Now I get it! 现在我懂了! Must use same name for the checkboxes like:
复选框必须使用相同的名称,例如:
checkbox_name[]
checkbox_name []
rather than using an array there .. ^_^ 而不是在那里使用数组.. ^ _ ^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.