/
borrowbak.php
executable file
·186 lines (148 loc) · 4 KB
/
borrowbak.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<title>rmitlibms | Borrow</title>
<meta name="description" content="Students borrow from the RMIT Library Management System."/>
<meta name="keywords" content="books, library, borrow books, library books, library staff, university booklist"/>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div class="navbarl">
<a href="login.php">Logout</a>
| <a href="home.php">Home</a>
</div>
<div class="navbarr">
<a href="search.html">Search</a>
| <strong>Borrow</strong>
| <a href="return.html">Return</a>
</div>
<div><br/></div>
<hr/>
<?php
$button1 = 'unchecked';
$button2 = 'unchecked';
$button3 = 'unchecked';
$button4 = 'unchecked';
$searched = $_GET['type'];
if (isset($searched))
{
$selected_button = $_GET['type'];
if ($selected_button == "author")
{
$button1 = "checked";
}
else if ($selected_button == "title")
{
$button2 = "checked";
}
else if ($selected_button == "keywords")
{
$button3 = "checked";
}
else if ($selected_button == "ISBN")
{
$button4 = "checked";
}
}
else
{
$button2 = "checked";
}
?>
<form action="borrow.php" method="get">
<div class="homesign">
<a href="search.html"><img src="logoxsmall.jpg" alt="rmitlibs" /></a><br/>
<input type="text" name="search" maxlength="110" size="43" value="" />
<input type="submit" value="Search" /><br/>
Search:
<input type="radio" name="type" value="author" <?php if($button1 == "checked"){echo "checked='checked'";} ?> />author
<input type="radio" name="type" value="title" <?php if($button2 == "checked"){echo "checked='checked'";} ?> />title
<input type="radio" name="type" value="keywords" <?php if($button3 == "checked"){echo "checked='checked'";} ?> />keywords
<input type="radio" name="type" value="ISBN" <?php if($button4 == "checked"){echo "checked='checked'";} ?> />ISBN<br/><br/>
</div>
</form>
<div class="results">
<strong>Search Results</strong>
</div>
<table class="borrow">
<?php
function borrow_button()
{
echo "<tr><td></td>";
echo "<td><p>";
echo "<form action='students.php' method='post'>";
echo "<input type='submit' name='borrow' value='Borrow'/>";
echo "</form>";
echo "</p></td></tr>";
}
function echoLine($line)
{
//This is possibly the coolest part of my assignment!!
$searchType = $_GET['type'];
echo "<tr><td>";
echo "<img src='return.png' alt='Book Photo' width='60' height='60' />";
echo "</td>";
echo "<td><p>";
echo "<strong><a href='./borrow.php?search=" . $line[0] . "&type=" . $searchType . "'>" . $line[0] . "</a></strong><br/>";
echo "<font color='grey'>by " . $line[1] . " - " . $line[2] . " - " . $line[3] . " - " . $line[4] . " pages</font><br/>";
echo $line[5] . "<br/>";
echo "<font color='#B22222'>Call Number: " . $line[6] . " | " . "Status: " . $line[7] . "</font>";
echo "<br/>";
echo "</p></td></tr>";
echo "\n";
}
function showBooks($fp)
{
while (!feof($fp))
{
$line = fgets($fp);
$element = split("\|", $line);
echoLine($element);
}
}
function getBooks()
{
$fp = fopen("books.txt","r");
rewind($fp);
$searched = $_GET['type'];
$_SESSION['search'] = $_GET['search'];
if(isset($searched))
{
if($_SESSION['search'] != '')
{
$searchType = $_GET['type'];
$titles = array("title","author","category","year","pages","notes","ISBN","status","keywords");
for($counter=0;$counter<count($titles);$counter++)
{
if($searchType == $titles[$counter])
{
$arrayNum = $counter;
}
}
while(!feof($fp))
{
$line = fgets($fp);
$element = split("\|", $line);
if(stristr($element[$arrayNum],$_SESSION['search']) == TRUE)
{
echoLine($element);
if(strcmp($element[$arrayNum],$_SESSION['search']) == 0)
{
borrow_button();
}
}
}
}
}
else
{
showBooks($fp);
}
}
getBooks();
?>
</table>
</body>
</html>