-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckitems.php
53 lines (52 loc) · 1.96 KB
/
checkitems.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
session_start();
?>
<!DOCTYPE HTML>
<html>
<head><title>Check Inventory</title></head>
<body>
<?php if($_SESSION["valid"] != 1){header("Location: index.php");}?>
<center><h1>Signed out Items</h1>
<table border="1"><tr><td><b><center>Item</center></b></td><td><b><center>With</center></b></td><td><b><center>NetID</center></b></td><td><b><center>Email</center></b></td><td><b><center>Sign Out Date</center></b></td></tr>
</center>
<?php
$dbname="db123";$servername = "sn123"; $username = "un123"; $password = "pw123";
$con = mysqli_connect($servername, $username, $password, $dbname);
if(!$con){
die("MYSQL Connection Failed:" . $con->connect_error);
}
$sql = "SELECT name, netid, date FROM signouts ORDER BY name;";
$results = $con->query($sql);
while($row = mysqli_fetch_array($results)){
$netid = $row["netid"];
$isql = "SELECT name, email FROM students WHERE netid = '$netid';";
$results2 = $con->query($isql);
$sinfo = mysqli_fetch_array($results2);
$sname = $sinfo["name"];
$item = $row["name"];
$email = $sinfo["email"];
$date = $row["date"];
echo "<tr><td>" . $item . "</td><td>" . $sname . "</td><td>" . $netid . "</td><td>" . $email . "</td><td>" . $date . "</td></tr>";
}
?>
</table>
<center><h1>Items still in stock (allegedly) </h1>
<table border = "1"><tr><td><b><center> Item Name </center></b></td></tr>
<?php
$dbname="db123";$servername = "sn123"; $username = "un123"; $password = "pw123";
$con = mysqli_connect($servername, $username, $password, $dbname);
if(!$con){
die("MYSQL Connection Failed:" . $con->connect_error);
}
$sql5 = "SELECT name FROM items WHERE checkedout = 0 ORDER BY name;";
$results = $con->query($sql5);
while($row = mysqli_fetch_array($results)){
$name = $row["name"];
echo "<tr><td><center>" . $name . "</center></td></tr>";
}
?>
</table>
<br><br>
<a href="home.php"><button>Go Home</button></a>
</body>
</html>