-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathviewAttributes.php
More file actions
67 lines (52 loc) · 1.85 KB
/
viewAttributes.php
File metadata and controls
67 lines (52 loc) · 1.85 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
<html>
<head>
<title>Pipoca</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<script>
function deleteAtt(n) {
if (confirm("If you delete this attribute, you will also loose the values for all sources. Do you want to proceed?")) {
window.location = "doDeleteAttribute.php?id=" + n;
}
}
</script>
</head>
<body>
<div id="#tudo">
<object data="css/logo.svg" type="image/svg+xml" height=200 width=900></object>
<div id="menu">
<?php include("menu.html"); ?>
</div>
<div id="centro">
<h2>Attributes</h2>
<?php
include("connection.php");
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id, name, memo FROM attributes";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "<div class='item'>\n";
echo "<span class='fieldname'>id:</span>" . $row["id"] . "<br>\n";
echo "<span class='fieldname'>Name:</span>" . $row["name"]. "<br>\n<span class='fieldname'>Description:</span>" . $row["memo"] . "<br>\n";
echo "<span class='fieldname'>Registered values:</span>";
//printing the values for this attribute in table sourceAttributes
$result2 = mysqli_query($conn, "SELECT DISTINCT value FROM sourceAttributes WHERE attributes_id='" . $row["id"] . "'");
while($row2 = mysqli_fetch_assoc($result2)) {
echo $row2["value"] . ", ";
}
echo "\n<br>\n<span class='fieldname'>actions:</span><a href='javascript:deleteAtt(" . $row["id"] .")'>Delete</a> | <a href='editTheAttribute.php?id=" . $row["id"] . "'>Edit</a>\n";
echo "\n</div>\n";
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
</body>
</html>