PHP引发Parse错误:语法错误,意外的“”

用户名

我建立了一个系统,员工可以在该系统中查看其请假状态。我试图根据用户是否登录来显示该请假状态。

这是一个例子:

查看我的假期

因此,登录的用户是John Doe,但是由于某种原因,我可以看到其他用户申请的其他假期。我只希望John Doe看到自己的叶子。

这是我想出的代码:

<div class="container">
    <div class="page-header">
        <h3>My Leaves</h3>
        <div class="table-responsive">
            <table class="table">
                <tr>
                    <th>Employee Name</th>
                    <th>Phone</th>
                    <th>Email</th>
                    <th>From</th>
                    <th>To</th>
                    <th>Reason</th>
                    <th>Status</th>
                </tr>
                <?php
                include ('database.php');
                $result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee ON employee.id = leaves.user_id WHERE employee.username = $_SESSION["VALID_USER_ID"]");
                $result ->execute();
                for ($count=0; $row_message = $result ->fetch(); $count++){ ?>
                <tr>
                    <td><?php echo $row_message['full_name']; ?></td>
                    <td><?php echo $row_message['phone']; ?></td>
                    <td><?php echo $row_message['email']; ?></td>
                    <td><?php echo $row_message['fromdate']; ?></td>
                    <td><?php echo $row_message['todate']; ?></td>
                    <td><?php echo $row_message['reason']; ?></td>
                    <td><?php echo $row_message['status']; ?></td>
                </tr>
                <?php } ?>
            </table>
            <a href="home"><button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-arrow-left"></i> Back</button></a>
        </div>
    </div>
</div>

不幸的是我越来越 Parse error: syntax error, unexpected '"'

在以下行中:

$result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee ON employee.id = leaves.user_id WHERE employee.username = $_SESSION["VALID_USER_ID"]");

我不确定这是什么。

这是我的表模式:

员工表

离开表

西瓦

您将如下更改查询并尝试。

$result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee ON employee.id = leaves.user_id WHERE employee.id = ".$_SESSION["VALID_USER_ID"]);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章