我试图找出如何从我执行的查询更新“日期”结果。 以下是用于执行初始查询的代码:
<?php
include ("config.php");
$result = mysqli_query($con,"SELECT * FROM redmine.issues join redmine.projects ON issues.project_id=projects.id where projects.name='".$_SESSION['name']."';");
echo "<table border='0' width='80%' cellpadding='0' cellspacing='2' id='datatable' class='table table-bordered table-condensed table-hover table-striped'>
<tr>
<th width='50%' align='left'>Milestone</th>
<th width='25%' align='left'>Template Date</th>
<th width='15%' align='left'>Due Date</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td align='left'><input class='hidden' type='text' name='subject' id='subject' value='" . $row['subject'] . "'>" . $row['subject'] . "</td>";
echo "<td align='left'>" . $row['created_on'] . "</td>";
echo "<td align='left'><input type='text' name='due_date' id='due_date' value='".$row['due_date']."'></td>";
echo "<td align='left'><input type='submit' value='Submit New Date'></td>";
echo "</tr>";
}
echo "</table>";
echo "<br />";
mysqli_close($con);
?>
这会给我这个结果:
---------------------------------------- Milestone | Created Date | Due Date ---------------------------------------- Milestone 1 | 01/22/2015 | 01/22/2015 ----------------------------------------
我希望能够在每个里程碑的“截止日期”文本框中键入新日期,并在我的mysql表中更新该里程碑的截止日期。
感谢任何帮助!
我现在有了这个脚本..但它似乎只是更新了最后一个mysql查询结果。例如,如果我检索到5个里程碑,我只能更新最后一英里的石头日期。如果我尝试更新其他4个里程碑日期,则不会更新。
<?php
include ("config.php");
// Get values from form
$subject=$_POST['subject'];
$due_date=$_POST['due_date'];
$result = mysqli_query($con,"UPDATE redmine.issues join redmine.projects ON issues.project_id=projects.id SET issues.due_date='$due_date' WHERE issues.subject='$subject' AND projects.name='".$_SESSION['name']."'");
// close connection
mysqli_close($con);
?>
答案 0 :(得分:0)
创建一个输入[type =“text”]字段,如下所示:
<input type="text" value="something" id="DueDate" data-id="12" onchange="function_update()"/>
在 function_update()中,通过 data-id =“12”获取当前ID,使用ajax获取 id =“DueDate”的值onchange事件。