php - 如何从表结构化数据中检索复选框值?
问题描述
我有一个表格,每列都有复选框,如下所示:
此表的代码:
'<form action="ecfcoursedata.php" method="post">';
"<table width='50%'>";
'<tr><th>e-Competence Level</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th></tr>';
foreach ($tree as $key => $term) {
'<tr><td>' . $term->name . '</td>'
for($i=1; $i<=5; $i++) {
'<td><input type="checkbox" name=' . $term->name . '-' . $i . '></td>';
}
'</tr>';
}
'</table></div>';
'<div class="ecf-submit"><input type="submit" value="Submit" name=' . $arg0 . '></div></form>';
当我单击提交时,我需要检查每一行和特定列的值。我怎样才能做到这一点?请在这方面帮助我。
解决方案
在您的 HTML 中假设它是
<input type="checkbox" name="test" value="value1">
当您提交到 php 时,您可以使用
isset($_POST['test']);
或者
if ($_POST['test'] == 'value1'){}
或者
$variable = $_POST['test'];
推荐阅读
- ios - 启动应用程序时如何克服此错误?
- javascript - TypeError:无法读取未定义 React JS 的属性“handleClick”
- html - 即使我声明它,我的网站格式也没有间隔
- python - 将数据帧作为时间序列处理时,将新数据帧与旧数据帧进行比较?
- swift - SKAction 对儿童的奇怪行为
- python-3.x - 将值分配给 ndarray 中的中断切片
- javascript - 如何将 Javascript 文件中的值返回到 Node.js,以便写入文件?
- linux - 我想 grep [Nodes]:ALL from
- python - 如何访问在 `with` 语句中创建的变量
- typescript - 打字稿中所有对象文字类型的子类型?