员工login之后~
要看自己的请假的记录(还未approve或reject的)~
却做不到~谁可以帮帮我?
要从我的database拿出的资料:
leave - applyDate,startDate, endDate,leaveType,reason
leaveHistory.php
- <?php
- session_start();
- if (isset($_POST['staffUsername'])) {
- $user = $_POST['staffUsername'];
- if (!isset($_SESSION["staffUsername"]) || $user != $_SESSION['staffUsername']) {
- header("Location: ../index.html");
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Apex Pharmacy</title>
- <link href="../css/styles.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <Center><img src="../image/newlogo.png" width="463" height="163" style="margin-top:-30px"/><br />
- <h2><span style="color: #FFFFFF">Leave Applied History
- </span>
- <button onclick="location.href='logout.php'">
- LOGOUT</button>
- <button onclick="location.href='staff.php'">
- Apply Leave</button>
-
- </h2></center><br />
-
- <?php
- $host = "localhost";
- $username = "root";
- $password ="";
- $dbname = "pharmacy";
-
- //create connection
- $conn = new mysqli($host, $username, $password, $dbname);
- //check connection
- if ($conn->connect_error) {
- die("Connection failed: ".$conn->connect_error);
- }
-
- // create query WHERE staff_username
- $query ="SELECT * FROM leave";
- // execute query
- $result = mysqli_query($conn,$query) or die ("Error in query: $query. ".mysql_error());
-
- //$result = mysqli_query($conn, "SELECT * FROM leave WHERE staff_username ='".$_SESSION['staffUsername']."'");
-
-
- if(mysqli_num_rows($result) > 0){
- echo "<table cellspacing='30'>";
- while($row = mysqli_fetch_array($result)) {
-
- echo "<tr><td>Apply Date:</td>";
- echo "<td>".$row["applyDate"]."</td></tr>";
- echo "<tr><td>Staff ID:</td>";
- echo "<td>".$id."</td></tr>";
-
-
- }
- echo "</table>";
- } else {
- echo "<center><b>There's no results in database!</b></center>";
- }
- mysqli_close($conn);
- ?>
- </body>
- </html>