MySQL查询更新列到数据库.但是它不能显示更新后的列值到页面中


php MySQL query update column into database.. But It can't show me the updated column value into page

你好,我是PHP和MYSQL的新手。想要了解更多。今天我面临一些问题,如更新值到数据库。但我解出来了。我的代码更新每一行的特定列名'状态'到数据库中。但是在

页显示的值还是一样的
<div class="widget-body" style="height: 290px;">
    <table class="table ">
        <thead>
            <tr>
                <th>User Name</th>
                <th>Starts</th>
                <th>Length</th>
                <th>Status</th>
                <th>Update</th>
            </tr>
        </thead>
        <tbody>   
            <?php
            include 'sql.php';
            $result = mysql_query("SELECT vacation.id, vacation.start_date, vacation.length, vacation.status, userinfo.* FROM vacation INNER JOIN userinfo ON vacation.user_id = userinfo.user_id ");
            if ($result === FALSE) {
                die(mysql_error()); // TODO: better error handling
            }
            while ($db_field = mysql_fetch_assoc($result)) {
                $id = $db_field['id'];
                $uid = $db_field['user_id'];
                $uname = $db_field['username'];
                $sdate = $db_field['start_date'];
                $len = $db_field['length'];
                $stat = $db_field['status'];
                echo("<tr>");
                echo("<td>$uname</td>");
                echo("<td>$sdate</td>");
                echo("<td>$len</td>");
                echo("<td>$stat</td>");
                ?> <td>
                <form method='post' action = '<?php echo $_SERVER['PHP_SELF'];?>' >    
                    <input  type='hidden' name="vacation_id" value='<?php echo $id; ?>'/>
                    <button type='submit' class='btn btn-success btn-mini' name='btn-accept' >Accept</button>
                </form>
                <form method='post' action = '<?php echo $_SERVER['PHP_SELF'];?>' >    
                    <input  type='hidden' name="vacation_id" value='<?php echo $id; ?>'/>
                    <button type='submit' class='btn btn-danger btn-mini'  name='btn-deny' >Deny</button>
                </form>
            </td><?php
                echo("</tr>");
            } //end while-loop
                ?>
            <?php
                if (isset($_POST['btn-accept'])) {
                    $v_id = $_POST['vacation_id'];
                    $SQL = "UPDATE vacation SET status = 1 WHERE id = $v_id ";
                    $result = mysql_query($SQL);
                    if ($result === FALSE) {
                        die(mysql_error()); // TODO: better error handling
                    }
                }
                if (isset($_POST['btn-deny'])) {
                    $v_id = $_POST['vacation_id'];
                    $SQL = "UPDATE vacation SET status = 0 WHERE id = $v_id ";
                    $result = mysql_query($SQL);
                    if ($result === FALSE) {
                        die(mysql_error()); // TODO: better error handling
                    }
                }
             ?>
        </tbody>
    </table>
</div>

我知道它很旧,但我正在学习。

我的意思是这样一点:

        if (isset($_POST['btn-accept'])) {
            $v_id = $_POST['vacation_id'];
            $SQL = "UPDATE vacation SET status = 1 WHERE id = $v_id ";
            $result = mysql_query($SQL);
            if ($result === FALSE) {
                die(mysql_error()); // TODO: better error handling
            }
       }
       if (isset($_POST['btn-deny'])) {
            $v_id = $_POST['vacation_id'];
            $SQL = "UPDATE vacation SET status = 0 WHERE id = $v_id ";                   
            $result = mysql_query($SQL)
            if ($result === FALSE) {
                die(mysql_error()); // TODO: better error handling
            }
        }
        $result = mysql_query("SELECT vacation.id, vacation.start_date, vacation.length, vacation.status, userinfo.* FROM vacation INNER JOIN userinfo ON vacation.user_id = userinfo.user_id ");
        if ($result === FALSE) {
            die(mysql_error()); // TODO: better error handling
        }
        while ($db_field = mysql_fetch_assoc($result)) {