-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·188 lines (163 loc) · 7.64 KB
/
index.php
File metadata and controls
executable file
·188 lines (163 loc) · 7.64 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
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
187
188
<?php
session_start();
if(!isset($_SESSION['library']))
header('Location: login.php');
?>
<!DOCTYPE html>
<html lang="it">
<head>
<title>Library</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="favicon.ico"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/table.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/prova.css">
<link rel="icon" type="image/png" href="favicon.png">
<style>
#myInput {
background-position: 10px 10px;
background-repeat: no-repeat;
width: 100%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
a:link {
text-decoration: none;
}
a:active {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Cerca" title="Type in a name">
<div class="limiter">
<div class="container-table100">
<div class="wrap-table100">
<div class="table100">
<table id="myTable">
<thead>
<tr class="table100-head">
<th class="column1">Titolo</th>
<th class="column2">Genere</th>
<th class="column3">Autore</th>
<th class="column4">Collana</th>
<th class="column5">Editore</th>
<th class="column6">Pubblicazione</th>
<th class="column7">Prezzo</th>
<th class="column8">ISBN</th>
</tr>
</thead>
<tbody>
<?php
$dsn = 'mysql:hosy=localhost;dbname=Biblioteca';
$username = 'phpmyadmin';
$password = 'qss-s3E-IH9_Khz';
try{
// connect to mysql
$con = new PDO($dsn,$username,$password);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (Exception $ex) {
echo 'Not Connected '.$ex->getMessage();
}
// mysql select query
$queryBook = $con->prepare('SELECT * FROM Libro ORDER BY Titolo');
$queryKind = $con->prepare('SELECT * FROM Genere');
$queryWriter = $con->prepare('SELECT TItolo, ISBN, Nome, Cognome FROM Libro, Autore, Libro_Autore WHERE ISBN = fk_Libro AND id_Autore = fk_Autore ORDER BY Titolo');
$queryPbHouse = $con->prepare('SELECT * FROM Casa_Editrice');
$queryBook->execute();
$queryKind->execute();
$queryWriter->execute();
$queryPbHouse->execute();
$result1 = $queryKind->fetchAll();
$result2 = $queryWriter->fetchAll();
$result3 = $queryPbHouse->fetchAll();
$result4 = $queryBook->fetchAll();
//KIND
$i=1;
foreach ($result1 as $row)
{
$kind[$i]=$row['Genere'];
$i++;
}
//Writer
$i=1;
foreach ($result2 as $row)
{
$writer[$i]=$row['Nome'].' '.$row['Cognome'];
$isbn[$i]=$row['ISBN'];
$i++;
}
$dim=$i;
//Publishing House
$i=1;
foreach ($result3 as $row)
{
$pbhouse[$i]=$row['Nome'];
$i++;
}
//Count the Books
$counter=0;
//Book
foreach ($result4 as $row)
{
echo '<tr>';
if($row['Titolo']=='') echo '<td class="column1"><center>-</center></td>'; else echo '<td class="column1"><a href="https://duckduckgo.com/'.$row['Titolo'].'">'.$row['Titolo'].'</a></td>';
if($row['fk_Genere']=='') echo '<td class="column2"><center>-</center></td>'; else echo '<td class="column2">'.$kind[$row['fk_Genere']].'</td>';
//if($row['fk_Autore']!='') echo '<td class="column3"><center>-</center></td>'; else echo '<td class="column3">'.$writer[].'</td>';
//It's for writer
echo '<td class="column3">';
for ($i = 1; $i <= $dim; $i++) { if ($isbn[$i]==$row['ISBN']) { echo $writer[$i]; $flag=1; } $i++; }
if($flag!=1) echo '-';
echo '</td>';
if($row['Collana']=='') echo '<td class="column4"><center>-</center></td>'; else echo '<td class="column4">'.$row['Collana'].'</td>';
if($row['fk_Casa_Editrice']=='') echo '<td class="column5"><center>-</center></td>'; else echo '<td class="column5">'.$pbhouse[$row['fk_Casa_Editrice']].'</td>';
if($row['Data_pubblicazione']=='') echo '<td class="column6"><center>-</center></td>'; else echo '<td class="column6">'.$row['Data_pubblicazione'].'</td>';
if($row['Prezzo']=='') echo '<td class="column7"><center>-</center></td>'; else echo '<td class="column7">€ '.$row['Prezzo'].'</td>';
if($row['ISBN']=='') echo '<td class="column8"><center>-</center></td>'; else echo '<td class="column8"> '.$row['ISBN'].'</td>';
echo '</tr>';
//Count the books
$counter++;
}
echo $counter;
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script>
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</body>
</html>