【发布时间】:2018-06-29 13:31:45
【问题描述】:
我创建了一个系统,员工可以在其中查看他们申请的休假状态。我正在尝试根据用户是否登录来显示已申请的休假状态。
这是一个例子:
所以登录的用户是 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"]");
我不确定它是什么。
这是我的表架构:
【问题讨论】:
-
只要把结尾改成
employee.username = " . $_SESSION["VALID_USER_ID"]);
标签: php html mysql database phpmyadmin