因此,关于我的困境,我已经对我的网站进行了编码,以将重新安排的类的列表返回到表中,供管理员批准或不批准。从数据库中检索此重新安排的类的列表。
我要查找的是,当单击“批准”按钮时,代码会将特定行的数据存储到数据库(let's say I want just the first row's data to be approved)中。我怎么做?我想尽可能使用主键来执行此操作,但是据我了解,主键不稳定,例如,如果删除了该列表中的条目,则该键不会被替换,而是会自动递增。
这是我的表格代码:
<div class="dashboard-content__panel " data-panel-id="class_replacement">
<div class="dashboard-list report-content">
<div id="report" class="panel panel-primary panel-table table-responsive reportTable" style="border:none; ">
<div class="panel-body " >
<table id="report-table" class="table table-hover" width="100%" >
<thead>
<tr>
<th>Subject Code</th>
<th>Subject Rescheduling Date and Subject Start Time</th>
<th>Duration (hours)</th>
<th>Status</th>
<th>Select Venue</th>
<th>Approve/Disapprove</th>
</tr>
</thead>
<tbody>
<?php
$conn = mysqli_connect("localhost", "root", "", "fyp1web");
if ($conn -> connect_error) {
die("Connection Failed: ". $conn-> connect_error);
}
$sql = "SELECT * from class_rescheduling";
$result = $conn-> query($sql);
while ($rs = $result-> fetch_assoc()) {
?>
<tr>
<td><?php echo $rs["newSubjectID"]; ?></td>
<td><?php echo $rs["newDateTime"]; ?></td>
<td><?php echo $rs["newDuration"]; ?></td>
<td><?php echo $rs["newStatus"]; ?></td>
<td> <select name="classname">
<?php
$sql2 = "SELECT className FROM class_rooms";
$result2 = $conn-> query($sql2);
while ($rs1 = mysqli_fetch_array($result2)) {
?>
<option value="<?php echo $rs1['className']; ?>"><?php echo $rs1["className"]; ?></option>
<?php
}
?>
</select></td>
<td><button class='btn' type='submit' name='approve'>Approve</button><button class='btn' type='submit' name='disapprove'>Disapprove</button></td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
</div>
</div>