Javascript I';我正在写两个查询,但第二个查询不起作用

Javascript I';我正在写两个查询,但第二个查询不起作用,javascript,php,html,Javascript,Php,Html,我正在编写两个查询,第一个查询工作正常,但第二个查询不工作。请引导我,谢谢 <table class="table table-bordered table-hover"> <form role="form" method="post" action=""> <div class="tablenav top"> <div class="alignleft actions bulkactions">

我正在编写两个查询,第一个查询工作正常,但第二个查询不工作。请引导我,谢谢

<table class="table table-bordered table-hover">
  <form role="form" method="post" action="">               
    <div class="tablenav top">
      <div class="alignleft actions bulkactions">
        <label for="bulk-action-selector-top" class="screen-reader-text">Comment Action</label><select name="comment_status" id="bulk-action-selector-top">
          <option value="" name="">Select Option</option>
          <option value="Approve" name="Approve">Approve</option>
          <option value="unapprove" name="unapprove" class="hide-if-no-js">Unapprove</option>
        </select>
        <input type="submit" name="submit" id="doaction" class="button action" value="Apply">
      </div>
      <br class="clear">
    </div>
    <thead>
      <tr>
        <th></th>
        <th>Id</th>
        <th>Author</th>
        <th>Comments</th>
        <th>Email</th>
        <th>Author Url</th>
        <th>Status</th>
        <th>Date</th>
        <th>Post Name</th>
        <th>Edit</th>
        <th>Delete</th>
        <th>Reply</th>
      </tr>
    </thead>
    <tbody>
      <?php
      $query = "SELECT * FROM comments";
      global $connection;
      $select_comments = mysqli_query($connection, $query) or die('Could not look up user information; ' . mysqli_error($connection));
      while ($row = mysqli_fetch_array($select_comments)) {
        $comment_id = $row['comment_id'];
        $comment_post_id = $row['comment_post_id'];
        $comment_author = $row['comment_author'];
        $comment_date = $row['comment_date'];
        $comment_email = $row['comment_email'];
        $comment_author_url = $row['comment_author_url'];
        $comment_content = $row['comment_content'];
        $comment_status = $row['comment_status'];

        echo "<tr>
                <td><input type='checkbox' name='check_list[]' value='$comment_id'></td>
                <td>$comment_id</td>
                <td>$comment_author</td>
                <td>$comment_content</td>
                <td>$comment_email</td>
                <td>$comment_author_url</td>
                <td>$comment_status</td>
                <td>$comment_date</td>
              </tr>";
      }
      if (isset($_POST['submit'])) {
        global $connection;
        global $errors;

        $comment_status = $_POST['comment_status'];
        $check_box = isset($_POST['check_list']) ? $_POST['check_list'] : '';

        //     error messages 
        $missingcheckbox = "<p><stong>Recored box not checked.Please check the checkbox.</strong></p>";

        //     for name feild 
        if (!$check_box) {
          $errors .= $missingcheckbox;
        }

        if ($errors) {
          $resultMessage = '<div class="alert alert-danger">' . $errors . '</div>';
          echo $resultMessage;
        } else {
          for ($i = 0; $i < count($_POST['check_list']); $i++) {
            $id = $_POST['check_list'][$i];
            if ($comment_status == 'Approve') {
              $query = "UPDATE comments SET comment_status = 'approved' WHERE comment_id = $id";
            } elseif ($comment_status == 'Unapprove') {
              $query = "UPDATE comments SET comment_status = 'unapproved' WHERE comment_id = $id";
            }

            if ($approve_comments = mysqli_multi_query($connection, $query)) {

            // header ("location: comments.php");
            // exit;

              $resultMessage = '<div class="alert alert-success">Data has been successfully Updated.<a href="../includes/comments.php"><img src="../../assets/img/refresh.png" alt="Edit Client" title="Refresh" style="width:30px; height:30px; border:0;"></a></div>';
              echo $resultMessage;
            } else {
              $resultMessage = '<div class="alert alert-warning">ERROR: Unable to excecute:' . $query . ' . ' . mysqli_error($connection) . '</div>';
              echo $resultMessage;
            }
          }
        }
      }
      ?>
    </tbody>   
</table>

比较两个字符串是否相同时,大小写很重要

<option value="unapprove"
              ^^^

比较两个字符串是否相同时,大小写很重要

<option value="unapprove"
              ^^^

$id是一个变量,您将其作为字符串放在那里。例如:

<?php
     $a = "Hello ";
     $b = $a . "World!"; // "Hello World!"

     $a = "Hello ";
     $a .= "World!";     // "Hello World!"
?>


你也必须这样做

$id是一个变量,您将其作为字符串放在那里。例如:

<?php
     $a = "Hello ";
     $b = $a . "World!"; // "Hello World!"

     $a = "Hello ";
     $a .= "World!";     // "Hello World!"
?>


你也必须这样做

什么不起作用?它会进入elseif吗?什么不起作用?它是不是进了elseif?