-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreader.php
More file actions
69 lines (64 loc) · 2.27 KB
/
Copy pathreader.php
File metadata and controls
69 lines (64 loc) · 2.27 KB
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
<?php
include_once "databaseQuery.php";
echo '<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="content">
<h2> Wykaz Czytelników z danego miasta </h2>';
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
echo '
<form method="post" action="reader.php" class="form-container">
<label for="optionvalue">Wartosc</label>
<select name="option" id="option">
<option value="name">Imie</option>
<option value="lastname">Nazwisko</option>
<option value="address">Adres</option>
</select><br>
<label for="optionvalue">Wartosc</label>
<input type="text" id="optionvalue" name="optionvalue"><br>
<input type="submit" value="Wyszukaj" class="btn">
</form>
';
}
else
{
echo '<table class="data-table">
<tr><td><b>name</b></td>
<td><b>lastname</b></td>
<td><b>Address</b></td>
<td><b>Books</b></td>
</tr>';
$query = new DatabaseQuery();
$readers = $query->getReaders();
foreach($readers ->reader as $reader)
{
$option = $_POST['option'];
$optionvalue = $_POST['optionvalue'];
$readerOption = $reader->name;
if($option === "lastname") {
$readerOption = $reader->lastname;
}
else if($option === "address") {
$readerOption = $reader->address;
}
if ((strcasecmp($readerOption, $optionvalue)) == 0)
{
$books = $query->getReaderBooks($reader["id"]);
$booksNames = array_map(function($book) { return $book->title; }, $books);
echo '<tr>';
echo "<td>".$reader->name."</td>";
echo "<td>".$reader->lastname."</td>";
echo "<td>".$reader->address."</td>";
echo "<td>".implode (", ", $booksNames)."</td>";
echo "</tr>";
}
}
echo '</table> </br></br>';
}
echo '<a href="reader.php" class="return">Odśwież</a> ';
echo '<a href="index.html" class="return">Stona główna</a>';
echo '</div> </body> </html>';
?>