我有一个php脚本,其中的表经过时间排序。 在该表中,我有一个复选框,以标记是否删除了东西,并且我有一个隐藏的输入,即获取ID。它昨天工作了,但知道它的ID在表中最低。
$sql = "SELECT * FROM `bestalning` WHERE lev=0
ORDER BY tid";
$result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
echo "<form method='POST' action='ID_change.php'>";
echo "<div class='continer bg-vit table-rsponsive-sm '><table class='table'><thead class='thead-dark'>
<tr><th >".'Lev'."</th><th>".' '."</th><th >".'Artikelnr'."</th><th >".'Antal'."</th>
<th >".'Singnatur'."</th><th >".'Önskad ankomst'."</th><th >".'Skickad'."</th></tr></thead></div>";
while($row = mysqli_fetch_array($result)){
echo "<tbody><tr><td><input style='margin-right:5px;' name='levJA' type='checkbox' value='1'></td><td>
<input style='margin-right:5px;' name='RowID' type='hidden' value='".$row['ID']."'></td><td>".$row['artikelnr']."</td>
<td>".$row['antal']."</td><td>".$row['ovrigt']."</td><td>".$row['Tid']."</td><td>".$row['date']."</td></tr></tbody>";
}
echo " <input class='btn btn-dark m-1' type='submit' value='submit'></form>";
mysqli_close($conn);
ID_change.php
$Lev = $_POST['levJA'];
$ID = $_POST['RowID'];
$sql = "UPDATE bestalning SET lev='".$Lev."' WHERE ID='".$ID."'";
echo $sql;
if (mysqli_query($conn, $sql,)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
mysqli_close($conn);
?>