/
lists.php
124 lines (110 loc) · 2.43 KB
/
lists.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
<?php
/*
* this page is for debugging.
* lists various schemas and tables.
* will eventually allow SQL execution for forther
* dubugging purposes.
*/
require_once 'page_base.php';
require_once 'db.php';
require_once 'helpers.php';
require_once 'dom.php';
/*
* list professors
*/
function list_instructors() {
$profs = get_all_profs();
$names = array();
while ($row = mysql_fetch_assoc($profs)) {
$names[] = $row['username'] . ' - ' . $row['first_name'] . ' ' . $row['last_name'];
}
dom::h3('section-title', 'List Professors');
dom::push_div('section');
dom::ul($names);
dom::pop();
}
/*
* list books
*/
function list_books() {
$books = get_all_books();
$names = array();
while ($row = mysql_fetch_assoc($books)) {
$names[] = $row['title'] . ' - ' . $row['isbn'] . ' - ' . $row['publisher'];
}
dom::h3('section-title', 'List Text Books:');
dom::push_div('section');
dom::ul($names);
dom::pop();
}
/*
* list courses
*/
function list_courses() {
$courses = get_all_courses();
$names = array();
while ($row = mysql_fetch_assoc($courses)) {
$names[] = $row['title'];
}
dom::h3('section-title', 'List Courses:');
dom::push_div('section');
dom::ul($names);
dom::pop();
}
/*
* list sections
*/
function list_sections() {
$sections = get_all_sections();
$names = array();
while ($row = mysql_fetch_assoc($sections)) {
$names[] = $row['crn'];
}
dom::h3('section-title', 'List Sections:');
dom::push_div('section');
dom::ul($names);
dom::pop();
}
class list_page extends base_page {
function header_title() {
return 'Lists for debugging';
}
function page_name() {
return 'lists.php';
}
/*
* this block handles all POST requests
*/
function handle_post($post) {
/*
* action for adding a professor
*/
if ($_POST['action'] == 'sql') {
}
else {
}
/*
* after POST save messages in session and redirect
* to same page but with a GET to avoid
* annoying POST resubmission messages
* on the browser's end.
*/
if (mysql_error()) {
$this->set_error(mysql_error());
}
}
function render_body() {
dom::h3('', 'Raw SQL');
dom::push_form('lists.php');
dom::textarea("sql");
dom::br();
dom::hidden('action', 'sql');
dom::submit();
dom::pop();
list_instructors();
list_sections();
list_books();
list_courses();
}
}
(new list_page())->dump();