12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- $id = $_GET['id'];
- include_once("../../untils/conn.php");
- if ($con) {
- mysqli_query($con, "set names utf8");
- $sql = "SELECT state FROM list WHERE id = '$id'";
- $result = mysqli_query($con, $sql);
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $state = $row["state"];
- }
- } else {
- echo "未找到匹配的记录";
- }
- if ($state == 0) {
- $new_state = 1;
- } else {
- $new_state = 0;
- }
- mysqli_query($con, "set names utf8");
- $sql = "UPDATE `list` SET state = '$new_state' WHERE id = '$id'";
- if ($con->query($sql) === TRUE) {
- echo "<script>alert('修改信息成功');window.location.href='../list.php'</script>";
- } else {
- echo "<script>alert('修改失败');window.location.replace(document.referrer)</script>";
- // echo "Error updating record: " . $con->error;
- }
- }
|