我建立了一个系统,员工可以查看他们的申请休假状态。我正在尝试根据用户是否登录来显示应用的休假状态。
以下是一个例子:
因此,登录的用户是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"]");
我不确定它是什么。
以下是我的表格模式:
答案 0 :(得分:1)
您将更改以下查询并尝试。
$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"]);