English 中文(简体)
多种相同要素的形式
原标题:Multiple instances of same elements in a form

从数据库中,我装上一些用户可以编辑的数据。

让我们这样说:

<form>
Name: [TextBox]
Data: [TextArea]
-------------------
Name: [TextBox]
Data: [TextArea]
...
Name: [TextBox]
Data: [TextArea]
-------------------
[Submit Button]
</form>

哪些内容?

采用PHP来计算所公布数据的最佳办法是什么,因此,我可以理解每个数据是什么样的。

注:我想到只有1份提交,但!

......

最佳回答

有了PHP,你就可以使用一个阵列:

Name: <input type="text" name="name[]" value="">
Data: <textarea name="data[]"></textarea>
...
Name: <input type="text" name="name[]" value="">
Data: <textarea name="data[]"></textarea>

然后,在PHP中,你可以这样做:

$nameArray = $_POST[ name ];
$dataArray = $_POST[ data ];
foreach($nameArray as $key => $name){
  $data = $dataArray[$key]);    
}

另一种方式是利用实验室生成姓名。 让他们看到:

Name: <input type="text" name="name[0]" value="">
Data: <textarea name="data[0]"></textarea>
Name: <input type="text" name="name[1]" value="">
Data: <textarea name="data[1]"></textarea>
...
Name: <input type="text" name="name[10]" value="">
Data: <textarea name="data[10]"></textarea>

这样,你就可以确定,_POST[名称][10]美元相当于_POST[数据][10]美元。

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签