-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathviewImages.php
More file actions
87 lines (70 loc) · 2.63 KB
/
Copy pathviewImages.php
File metadata and controls
87 lines (70 loc) · 2.63 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
<html>
<head>
<title>Pipoca</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<style>
img {
float: left;
margin: 0 20px 10px 0;
width: 150px;
}
.item {
}
</style>
</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>Latest sources inserted</h2>
<?php
include("connection.php");
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
//getting the lastest date
$sql = "SELECT date FROM sources ORDER BY date DESC LIMIT 1";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$d = $row["date"];
//getting the registers inserted at the same date as the latest
$sql = "SELECT * FROM sources WHERE date='" . $d . "'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
echo "\n<br>\nNumber of results: " . mysqli_num_rows($result) . "\n<br><br>\n";
while($row = mysqli_fetch_assoc($result)) {
//basic info from the sources table
echo "<div class='item'>";
if ($row["type"]=="i") {
echo "<img src='sources/" . $row["name"]. "'>\n";
}
if ($row["type"]=="v") {
echo "<img src='css/video-icon.png'>\n";
}
echo "<span class='fieldname'>ID: </span><span class='fieldvalue'>" . $row["id"]. "</span><br/><span class='fieldname'>Description: </span><span class='fieldvalue'>" . $row["memo"]. "</span><br/>";
//getting and showing the attributes
$result2 = mysqli_query($conn, "SELECT * FROM (SELECT sourceAttributes.value, attributes.name, sourceAttributes.source_id FROM sourceAttributes INNER JOIN attributes ON sourceAttributes.attributes_id=attributes.id)fusao WHERE source_id=" . $row["id"]);
echo "<span class='fieldname'>Atributes:</span>\n";
while($row2 = mysqli_fetch_assoc($result2)) {
echo $row2["name"] . "=" . $row2["value"] . " , ";
}
echo "\n<br>\n<a class=''actions' href='viewImagewithBites.php?idImage=" . $row["id"] . "'>View</a> | <a class='actions' href='editAttributes.php?idImage=" . $row["id"] . "'>Edit attributes</a> | <a class='actions' href='applyCodes.php?idImage=" . $row["id"] . "'>Apply code</a>\n";
echo "\n<div style='clear: both;'><!-- --></div>\n</div>\n";
}
}
else {
echo ":( I could not find any image matching your criteria...";
}
mysqli_close($conn);
?>
</div>
</div>
</body>
</html>