shangjia.php 854 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. $id = $_GET['id'];
  3. include_once("../../untils/conn.php");
  4. if ($con) {
  5. mysqli_query($con, "set names utf8");
  6. $sql = "SELECT state FROM list WHERE id = '$id'";
  7. $result = mysqli_query($con, $sql);
  8. if ($result->num_rows > 0) {
  9. while($row = $result->fetch_assoc()) {
  10. $state = $row["state"];
  11. }
  12. } else {
  13. echo "未找到匹配的记录";
  14. }
  15. if ($state == 0) {
  16. $new_state = 1;
  17. } else {
  18. $new_state = 0;
  19. }
  20. mysqli_query($con, "set names utf8");
  21. $sql = "UPDATE `list` SET state = '$new_state' WHERE id = '$id'";
  22. if ($con->query($sql) === TRUE) {
  23. echo "<script>alert('修改信息成功');window.location.href='../list.php'</script>";
  24. } else {
  25. echo "<script>alert('修改失败');window.location.replace(document.referrer)</script>";
  26. // echo "Error updating record: " . $con->error;
  27. }
  28. }