JBTALKS.CC
标题:
紧急! 哪位大神可以帮帮我~~php and database
[打印本页]
作者:
忧郁晴天
时间:
2014-11-26 01:53 PM
标题:
紧急! 哪位大神可以帮帮我~~php and database
问题:
员工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>
复制代码
作者:
exchange321
时间:
2014-11-26 08:44 PM
试试看第38行改成:
$conn = @mysqli($host, $username, $password, $dbname);
作者:
leon_lcl
时间:
2014-11-26 10:40 PM
61行的 echo "<td>".$id."</td></tr>";
$id 哪里来的?
作者:
忧郁晴天
时间:
2014-12-7 09:08 PM
已解决~~谢谢~
欢迎光临 JBTALKS.CC (https://www.jbtalks.cc/)
Powered by Discuz! X2.5