-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager_database.php
68 lines (62 loc) · 2.04 KB
/
manager_database.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require_once 'shared_functions.php';
requireEmployeeLogin();
function showExampleQuery($description, $query) {
echo "
<form action='manager_database.php' method='post' id='{$description}'>
<input type='hidden' name='query' value='{$query}'>
<a href='#' onclick='submitQuery(\"{$description}\"); return false;'>
{$description}
</a>
</form>";
}
function showExampleQueries() {
echo "
<br>
<fieldset>
<legend>Example Queries</legend>";
showExampleQuery(
"Show Books",
"SELECT * FROM books JOIN inventory on books.isbn = inventory.isbn;");
showExampleQuery("Show Customers", "SELECT * FROM customers;");
showExampleQuery("Show Employees", "SELECT * FROM employees;");
showExampleQuery("Show Orders", "SELECT * FROM orders;");
showExampleQuery(
"Show Customer Addresses",
"SELECT customer_id, street_number, street_name, city, state, zip_code " .
"FROM customer_address INNER JOIN address USING " .
"(street_number, street_name, city, state);");
showExampleQuery("Show Employee Addresses",
"SELECT employee_id, street_number, street_name, city, state, zip_code " .
"FROM employee_address INNER JOIN address USING " .
"(street_number, street_name, city, state);");
showExampleQuery("Show Customer Reviews", "SELECT * FROM comments;");
showExampleQuery("Show Suppliers", "SELECT * FROM suppliers;");
echo "</fieldset>";
}
showHeader('Direct Access to Database');
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<legend>Enter the query below</legend>
<p class="form">
<label>Query: </label>
<textarea name="query" style='vertical-align: middle;'
cols='50' rows='2'><?php echo $_POST['query'] ?></textarea>
</p>
</fieldset>
<br>
<input type="submit" class="button" name="submit" value="Submit">
<br>
</form>
<br>
<script>
function submitQuery(name) {
document.getElementById(name).submit();
}
</script>
<?php
processManagerQuery();
showExampleQueries();
showFooter();
?>