【发布时间】:2014-09-13 07:54:51
【问题描述】:
我正在尝试为用户可以填写的表单编写 html5 和 PHP。当他们点击提交时,我希望有一个整体评估类别,每 5 列分组,我也可以检索。例如:
<parameters>
<parameterID>9214</parameterID>
<parameter>MC Bands</parameter>
<Yevaluation/>
<Mevaluation/>
<Cevaluation/>
<Kevaluation/>
<comments/>
</parameters>
<parameters>
<parameterID>9245</parameterID>
<parameter>MC Streaks</parameter>
<Yevaluation/>
<Mevaluation/>
<Cevaluation/>
<Kevaluation/>
<comments/>
</parameters>
我无法将其输入到表单和输入表中,因此我可以稍后将其检索为类别 ID。我本来打算找一个隐藏的单元格,但它会将值粘贴在第一个表格单元格中。
这是在 table.php 中:
<form method="get" action="visEupload.php">
<table id="bigTable" border="1">
<thead>
<tr>
<th id="bandY" class="col3">Bands @263mm Y</th>
<th id="bandM" class="col3">Bands @263mm M</th>
<th id="bandC" class="col3">Bands @263mm C</th>
<th id="bandK" class="col3">Bands @263mm K</th>
<th id="Comments" class="col3">Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td><input name="MCBands" value="9214" id="MCBands" visibility=hidden> <!--this isn't showing up as hidden-->
<td><input name="Yevaluation" ></td> //Row 0 Column 1
<td><input name="Mevaluation" ></td> //Row 0 Column 2
<td><input name="Cevaluation" ></td> //Row 0 Column 3
<td><input name="Kevaluation" ></td> //Row 0 Column 4
<td><input name="comment" ></td> //Row 0 Column 4
<!--the above rows will repeat with different id's/names/values/cells, ex. streaks and will be really wide-->
</tr>
</tbody>
</table>
<input id="submit" type="submit" class="list" name="submit" value="Submit To Database" >
</form>
我很难找到与表单一起提交的表格数据的良好示例。我看到了这个,但它不一样 html tables 。
点击提交后,我在 visEupload.php 中像这样检索它,但考虑到我每隔几行添加的额外参数 ID,也许有更好的方法:
if (isset($_GET['submit'])){
$Yevaluation= $_GET['Yevaluation'];
$Mevaluation= $_GET['Mevaluation'];
$Cevaluation= $_GET['Cevaluation'];
$Kevaluation= $_GET['Kevaluation'];
$MCBands= $_GET['MCBands'];
$comment=$_GET['comment'];
echo "here:".$Yevaluation.$Mevaluation.$Cevaluation.$Kevaluation.$MCBands.$comment;
echo "here1";
echo ("visE upload requested");
} //submit is set
【问题讨论】:
-
您可以通过使用类似数组的元素名称来做到这一点。请参阅我的回答 here 了解更多信息
标签: php html forms html-table http-get