如何提交带有分组/ ID的表格/表格以供稍后检索 [英] How to submit table/form with grouping/id to retrieve later
问题描述
我正在尝试为用户填写的表单编写html5和PHP。当他们提交时,我想要有一个总体评估类别,每5列分组下我也可以检索。例如:
<参数>
< parameterID> 9214< / parameterID>
< parameter> MC Bands< / parameter>
< Yevaluation />
<评估/>
< Cevaluation />
< Kevaluation />
< comments />
< /参数>
<参数>
< parameterID> 9245< / parameterID>
<参数> MC Streaks< / parameter>
< Yevaluation />
<评估/>
< Cevaluation />
< Kevaluation />
< comments />
< /参数>
我无法在表单和输入表中找到它,所以我可以稍后为类别ID。我打算去寻找一个隐藏的单元格,但它将价值坚持在第一个表格单元格中。
这是在table.php中:
< form method =getaction =visEupload.php>
< table id =bigTableborder =1>
< thead>
< tr>
< th id =bandMclass =col3>乐队@ 263mm M< / th>
< th id =bandCclass =col3>乐队@ 263mm C< / th>
< th id =bandKclass =col3> 263mm K带< / th>
< / tr>
< / thead>
< tbody>
< tr>
< td><输入名称=MCBandsvalue =9214id =MCBandsvisibility = hidden> <! - 这不会显示为隐藏 - >
< td>< input name =Yevaluation>< / td> //行0列1
< td><输入名称=评估>< / 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
<! - 上面的行将以不同的id / names / values / cells重复,例如。条纹并且将会非常宽 - >
< / tr>
< / tbody>
< / table>
< input id =submittype =submitclass =listname =submitvalue =Submit To Database>
< / form>
我无法找到使用表单提交的表格数据的好例子。我看到这个,但它不同于 html表格。
在我提交后,我在visEupload.php中像这样检索它,但是可能有更好的方法来完成它,因为我添加了额外的参数ID每隔几行:
if(isset($ _ GET ['submit'])){
$ Yevaluation = $ _GET [ 'Yevaluation'];
$评估= $ _GET ['Mevaluation'];
$ Cevaluation = $ _GET ['Cevaluation'];
$ Kevaluation = $ _GET ['Kevaluation'];
$ MCBands = $ _GET ['MCBands'];
$ comment = $ _ GET ['comment'];
echohere:。$ Yevaluation。$ Mevaluation。$ Cevaluation。$ Kevaluation。$ MCBands。$ comment;
echohere1;
echo(visE upload requested);
$ b $} // submit is set
您可以在输入元素中使用类似数组的名称,例如:
< table id =bigTableborder = 1\" >
< thead>
< tr>
< th id =bandMclass =col3>乐队@ 263mm M< / th>
< th id =bandCclass =col3>乐队@ 263mm C< / th>
< th id =bandKclass =col3> 263mm K带< / th>
< / tr>
< / thead>
< tbody>
< tr>
< td>< input name =MCBands []value =9214id =MCBandstype =hidden>
< td>< input name =Yevaluation []value =>< / td> // Row 0 Column 1
< td>< input name =Mevaluation []value =>< / td> // Row 0 Column 2
< td>< input name =Cevaluation []value =>< / td> // Row 0 Column 3
< td>< input name =Kevaluation []value =>< / td> // Row 0 Column 4
< td>< input name =comment []value =>< / td> //第0行第4列
< / tr>
< tr>
< td>< input name =MCBands []value =9215id =MCBandstype =hidden>
< td>< input name =Yevaluation []value =>< / td> // Row 0 Column 1
< td>< input name =Mevaluation []value =>< / td> // Row 0 Column 2
< td>< input name =Cevaluation []value =>< / td> // Row 0 Column 3
< td>< input name =Kevaluation []value =>< / td> // Row 0 Column 4
< td>< input name =comment []value =>< / td> //第0行第4列
< / tr>
< tr>
< td>< input name =MCBands []value =9214id =MCBandstype =hidden>
< td>< input name =Yevaluation []value =>< / td> // Row 0 Column 1
< td>< input name =Mevaluation []value =>< / td> // Row 0 Column 2
< td>< input name =Cevaluation []value =>< / td> // Row 0 Column 3
< td>< input name =Kevaluation []value =>< / td> // Row 0 Column 4
< td>< input name =comment []value =>< / td> //第0行第4列
< / tr>
< / tbody>
< / table>
在后端,您可以使用:
< pre $ if(isset($ _ GET ['submit'])){
$ arr = array();
foreach($ _ POST [MCBands]为$ key => $ val){
$ arr [] = array(
MCBands=> $ _POST [MCBands ] [$ key],
Yevaluation=> $ _POST [Yevaluation] [$ key],
Mevaluation=> $ _POST [Mevaluation] [$ key],
Cevaluation=> $ _POST [Cevaluation] [$ key],
Kevaluation=> $ _POST [Kevaluation] [$ key],
comment => $ _POST [comment] [$ key]
); //在这里添加分号〜M
}
}
I'm trying to write html5 and PHP for a form that the user can fill out. When they hit submit, I want there to be an overall evaluation category that every 5 columns are grouped under that I can retrieve also. For example:
<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>
I'm having trouble getting this into the form and input table so I can retrieve it later for the category ID. I was going to go for a hidden cell, but it's sticking the value in the first table cell.
This is in 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>
I'm having trouble finding a good example with table data submitted with a form. I saw this but it's different html tables .
After I hit submit, I'm retrieving it like this in visEupload.php, but maybe there's a better way to do it given the extra parameterID I'm adding in every few rows:
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
You can use array like names in your input elements like:
<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" type="hidden">
<td><input name="Yevaluation[]" value=""></td> //Row 0 Column 1
<td><input name="Mevaluation[]" value=""></td> //Row 0 Column 2
<td><input name="Cevaluation[]" value=""></td> //Row 0 Column 3
<td><input name="Kevaluation[]" value=""></td> //Row 0 Column 4
<td><input name="comment[]" value=""></td> //Row 0 Column 4
</tr>
<tr>
<td><input name="MCBands[]" value="9215" id="MCBands" type="hidden">
<td><input name="Yevaluation[]" value=""></td> //Row 0 Column 1
<td><input name="Mevaluation[]" value=""></td> //Row 0 Column 2
<td><input name="Cevaluation[]" value=""></td> //Row 0 Column 3
<td><input name="Kevaluation[]" value=""></td> //Row 0 Column 4
<td><input name="comment[]" value=""></td> //Row 0 Column 4
</tr>
<tr>
<td><input name="MCBands[]" value="9214" id="MCBands" type="hidden">
<td><input name="Yevaluation[]" value=""></td> //Row 0 Column 1
<td><input name="Mevaluation[]" value=""></td> //Row 0 Column 2
<td><input name="Cevaluation[]" value=""></td> //Row 0 Column 3
<td><input name="Kevaluation[]" value=""></td> //Row 0 Column 4
<td><input name="comment[]" value=""></td> //Row 0 Column 4
</tr>
</tbody>
</table>
And on backend, you can use:
if (isset($_GET['submit'])){
$arr = array();
foreach($_POST["MCBands"] as $key => $val) {
$arr[] = array(
"MCBands" => $_POST["MCBands"][$key],
"Yevaluation" => $_POST["Yevaluation"][$key],
"Mevaluation" => $_POST["Mevaluation"][$key],
"Cevaluation" => $_POST["Cevaluation"][$key],
"Kevaluation" => $_POST["Kevaluation"][$key],
"comment" => $_POST["comment"][$key]
); //semicolon added here ~M
}
}
这篇关于如何提交带有分组/ ID的表格/表格以供稍后检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!