forked from csc325/GCal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
categories.php
executable file
·136 lines (111 loc) · 3.38 KB
/
categories.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/*
* categories.php: Original Version of category management feature
* categoryAdmin2.php is current version
* PHP version 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category Administrator Functions
* @author CSC-325 Database and Web Application Fall 2010 Class
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version 1.0
* @deprecated File deprecated since version 3.0 categoryAdmin2.php
*/
/*Require html header and global variables*/
require_once 'global.php';
require_once 'header.php';
echo '<div class="body">';
echo '<div class="col large">';
if ($_POST) {
$query_delete = 'UPDATE categories SET permanent=0 WHERE categoryID = ';
$query_add = 'UPDATE categories SET permanent=1 WHERE categoryID = ';
$add_array = array_keys($_POST, 'add');
$delete_array = array_keys($_POST, 'delete');
if ($addArray) {
$query_add .= implode(' OR categoryID = ', $add_array);
$result_add = mysql_query($query_add);
echo mysql_error();
/* To do: error check */
}
if ($delete_array) {
$query_delete .= implode(' OR categoryID = ', $delete_array);
$result_delete = mysql_query($query_delete);
echo mysql_error();
/* To do: error check */
}
}
$query_perm = "SELECT * FROM categories
WHERE permanent=1
ORDER BY requestCount DESC,
categoryName ASC";
$result_perm = mysql_query($query_perm);
$query_temp = "SELECT * FROM categories
WHERE permanent=0
ORDER BY requestCount DESC,
categoryName ASC";
$result_temp = mysql_query($query_temp);
?>
<form name="categoryPerm" action="categories.php" method="post">
<table>
<tr>
<td colspan="3">
<h1>Permanent Categories</h1>
</td>
</tr>
<tr>
<th>Category</th>
<th>Requests</th>
<th>Delete</th>
</tr>
<?php while ($row = mysql_fetch_assoc($resultPerm)) : ?>
<tr>
<td><?php echo $row['categoryName']; ?></td>
<td><?php echo $row['requestCount']; ?></td>
<td><input type="checkbox" name="<?php echo $row['categoryID']; ?>" value="delete"></td>
</tr>
<?php endwhile; ?>
<tr>
<td colspan="3">
<h1>Temporary Categories</h1>
</td>
</tr>
<tr>
<th>Category</th>
<th>Requests</th>
<th>Add</th>
</tr>
<?php while ($row = mysql_fetch_assoc($resultTemp)) : ?>
<tr>
<td><?php echo $row['categoryName']; ?></td>
<td><?php echo $row['requestCount']; ?></td>
<td><input type="checkbox" name="<?php echo $row['categoryID']; ?>" value="add"></td>
</tr>
<?php endwhile; ?>
</table>
<input type="submit" value="update">
</form>
<style type="text/css">
table {
margin: 10px 10px 10px 0;
}
td, th {
padding: 5px;
border: 1px solid #ccc;
}
th {
text-align: left;
font-size: 14px;
color: #555;
}
</style>
<?php
echo '</div>';
require_once 'sidebar.php';
echo '</div>';
require_once 'footer.php';
?>