好的,我有一个设置为显示从数据库中提取的信息的表。
在这张表的最后,我有一个更新按钮。我正在使用引导程序,当您单击此按钮时,您会打开一个带有表单的模式,我希望将特定行中的值传递到表单中,以便用户可以编辑信息。
该表是这样生成的:
<?php
$con=mysqli_connect("50.63.106.181","TheGreenPandaWeb","MacBook1!","TheGreenPandaWeb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query = "SELECT * FROM affiliate_tasks WHERE username = '$_SESSION[username]'";
if( isset($_POST['sort-selection']) && $_POST['sort-selection'] != 'all' )
{
$query .= " AND status = '". $_POST['sort-selection']."';" ;
}
$result = mysqli_query($con, $query);
echo "<table class='table table-message table-hover'>
<tr class='heading'>
<td class='cell-title'>Tasks</td>
<td class='cell-status hidden-phone hidden-tablet'>Status</td>
<td class='cell-time align-right'>Due Date</td>
<td class='check-box' width='10px'> </td>
<td class='check-box' width='10px'> </td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr class='task " . ($row['resolved'] == 1 ? 'resolved' : '') . "' id='task-$row[task_id]'>";
echo "<td class='cell-ttle'>" . $row['task_name'] . "</td>";
echo "<td class='cell-status hidden-phone hidden-tablet " . ($row['status'] == Done ? 'text-success' : '') ." " . ($row['status'] == Overdue ? 'text-warning' : '') ."'>" . $row['status'] . "</td>";
echo "<td class='cell-time align-right'>" . $row['due_date'] . "</td>";
echo "<td class='check-box' width='10px'>" . "<a class='icon-arrow-up' href='#updateTaskModal' role='button' data-toggle='modal'></a>" . "</td>";
echo "<td class='check-box' width='10px'>" . "<a class='icon-remove' href='#deleteTaskModal' role='button' data-toggle='modal'></a>" . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
表格看起来像这样:
<form class="form-horizontal" name="new_task" action="scripts/form_scripts/new_task.php" method="post">
<div class="control-group">
<div class="controls">
<input type="text" name="username" id="username" class="hide" value="<?php session_start(); echo $_SESSION[username]; ?>">
</div>
</div>
<div class="control-group">
<label class="control-label" for="task_name">Task Name</label>
<div class="controls">
<input type="text" name="task_name" id="task_name" placeholder="Something with description.">
</div>
</div>
<div class="control-group">
<label class="control-label" for="status">Task Status</label>
<div class="controls">
<select id="status" name="status">
<option value="Pending">Pending</option>
<option value="In Progress">In Progress</option>
<option value="Done">Done</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="due_date">Due Date</label>
<div class="controls">
<input type="date" name="due_date" id="due_date" placeholder="mm/dd/yyyy">
</div>
</div>
我想您将需要 javascript,但我不确定从哪里开始。