我有一张桌子 <form id="project-form"> <table id="project-table" class="table table-striped table-inverse table-responsive"> <caption>Projects</caption> <thead class="thead-inverse"> <tr> <th scope="col">#</th> <th scope="col">Project name</th> <th scope="col">Description</th> <th scope="col">Estimated time (min)</th> <th scope="col">Actual time (min)</th> <th scope="col">Add task</th> <th scope="col">Delete project</th> </tr> </thead> <tbody id="project-body"> </tbody> </table> </form>此表填充了来自 AJAX GET 请求的数据function getProjects() { $.ajax({ method: 'GET', dataType: 'json', data: { functionToCall: 'project', }, url: 'http://localhost/WBS/php/api/requests/get.php', success: (response) => { $.each(response, function () { $.each(this, function (index, value) { $('#project-body').append( ` <tr> <td> <input class="form-control" type="hidden" name="projectid" id="projectid" value="${value.projectid}"> </td> <td> <input class="form-control" type="text" name="projectName" id="projectName" value="${value.title}"> </td> <td> <input class="form-control" type="text" name="description" id="description" value="${value.description}"> </td>
1 回答

慕村225694
TA贡献1880条经验 获得超4个赞
我认为您可以重命名您的输入,例如:
name="projectid[]"
然后 PHP 将收到这些值的数组:
$total = count($_POST["projectid"]);
for ($i = 0; $i < $total; $i++) {
$title = $_POST["projectName"][$i];
$description = $_POST["description"][$i];
$estimatedTime = $_POST["estimatedTime"][$i];
$actualTime = $_POST["actualTime"][$i];
// Your INSERT query is performed here
}
- 1 回答
- 0 关注
- 75 浏览
添加回答
举报
0/150
提交
取消