-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
202 lines (172 loc) · 6.24 KB
/
index.php
File metadata and controls
202 lines (172 loc) · 6.24 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
session_start();
if (!isset($_SESSION["user_logged_in"]) || $_SESSION["user_logged_in"] !== true) {
header("Location: ".$_SERVER['REMOTE_HOST']. "/plataforma/painel/index.php");
exit();
}
// Include the file for database connection
include 'conexao.php';
// Checking the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Query to select data from the English table
$sql_en = "SELECT * FROM granna80_bdlinks.roadmap_en";
$result_en = $conn->query($sql_en);
// Query to select data from the Spanish table
$sql_es = "SELECT * FROM granna80_bdlinks.roadmap_es";
$result_es = $conn->query($sql_es);
// Query to select data from the Portuguese table
$sql_pt = "SELECT * FROM granna80_bdlinks.roadmap_pt";
$result_pt = $conn->query($sql_pt);
// Query to select data from the English table for mobile devices
$sql_en_mobile = "SELECT * FROM granna80_bdlinks.roadmap_en_mobile";
$result_en_mobile = $conn->query($sql_en_mobile);
// Query to select data from the Spanish table for mobile devices
$sql_es_mobile = "SELECT * FROM granna80_bdlinks.roadmap_es_mobile";
$result_es_mobile = $conn->query($sql_es_mobile);
// Query to select data from the Portuguese table for mobile devices
$sql_pt_mobile = "SELECT * FROM granna80_bdlinks.roadmap_pt_mobile";
$result_pt_mobile = $conn->query($sql_pt_mobile);
?>
<!DOCTYPE html>
<html>
<head>
<title>Roadmap </title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
.highlighted {
background-color: yellow;
display: inline;
padding: 0;
}
</style>
</head>
<body>
<h2>Roadmap </h2>
<a href="add.php">Add new</a>
<table>
<tr>
<th>ID</th>
<th>Date</th>
<th>Done</th>
<th>Goal ENGLISH</th>
<th>Goal ENGLISH MOBILE</th>
<th>Goal ESPANISH</th>
<th>Goal ESPANISH MOBILE</th>
<th>Goal PORTUGUESE</th>
<th>Goal PORTUGUESE MOBILE</th>
<th>Semester</th>
<th>Edit</th> <!-- New column for edit buttons -->
</tr>
<?php
// Initialize index counters
$index = 1;
// Loop until there are results in at least one of the tables
while (true) {
$row_en = $result_en->fetch_assoc();
$row_es = $result_es->fetch_assoc();
$row_pt = $result_pt->fetch_assoc();
$row_en_mobile = $result_en_mobile->fetch_assoc();
$row_es_mobile = $result_es_mobile->fetch_assoc();
$row_pt_mobile = $result_pt_mobile->fetch_assoc();
// If there are no more results in any of the tables, end the loop
if (!$row_en && !$row_es && !$row_pt && !$row_en_mobile && !$row_es_mobile && !$row_pt_mobile) {
break;
}
echo "<tr>";
echo "<td>".$index."
</td>";
// Check and display task date in English
echo "<td>";
if ($row_en) {
echo date('d/m/Y', strtotime($row_en["task_date"]));
}
echo "</td>";
// Check and display if task is done
echo "<td>";
if ($row_en && $row_en["task_done"] == 1) {
echo "✓";
} else if ($row_en) {
echo "No";
}
echo "</td>";
// Check and display task goal in English
echo "<td>";
if ($row_en && $row_en["task_highlighted"] == 1) {
echo "<span class='highlighted'>".$row_en["task_goal"]."</span>";
} else if ($row_en) {
echo $row_en["task_goal"];
}
echo "</td>";
// Check and display task goal in English for mobile devices
echo "<td>";
if ($row_en_mobile && $row_en_mobile["task_highlighted"] == 1) {
echo "<span class='highlighted'>".$row_en_mobile["task_goal"]."</span>";
} else if ($row_en_mobile) {
echo $row_en_mobile["task_goal"];
}
echo "</td>";
// Check and display task goal in Spanish
echo "<td>";
if ($row_es && $row_es["task_highlighted"] == 1) {
echo "<span class='highlighted'>".$row_es["task_goal"]."</span>";
} else if ($row_es) {
echo $row_es["task_goal"];
}
echo "</td>";
// Check and display task goal in Spanish for mobile devices
echo "<td>";
if ($row_es_mobile && $row_es_mobile["task_highlighted"] == 1) {
echo "<span class='highlighted'>".$row_es_mobile["task_goal"]."</span>";
} else if ($row_es_mobile) {
echo $row_es_mobile["task_goal"];
}
echo "</td>";
// Check and display task goal in Portuguese
echo "<td>";
if ($row_pt && $row_pt["task_highlighted"] == 1) {
echo "<span class='highlighted'>".$row_pt["task_goal"]."</span>";
} else if ($row_pt) {
echo $row_pt["task_goal"];
}
echo "</td>";
// Check and display task goal in Portuguese for mobile devices
echo "<td>";
if ($row_pt_mobile && $row_pt_mobile["task_highlighted"] == 1) {
echo "<span class='highlighted'>".$row_pt_mobile["task_goal"]."</span>";
} else if ($row_pt_mobile) {
echo $row_pt_mobile["task_goal"];
}
echo "</td>";
// Display the semester, fetching from any of the tables
echo "<td>";
if ($row_en) {
echo $row_en["semester"];
} else if ($row_es) {
echo $row_es["semester"];
} else if ($row_pt) {
echo $row_pt["semester"];
}
echo "</td>";
// Add an edit button for each row
echo "<td><a href='editar.php?id_en=" . ($row_en ? $row_en["task_id"] : "") . "&id_es=" . ($row_es ? $row_es["task_id"] : "") . "&id_pt=" . ($row_pt ? $row_pt["task_id"] : "") . "&id_en_mobile=" . ($row_en_mobile ? $row_en_mobile["task_id"] : "") . "&id_es_mobile=" . ($row_es_mobile ? $row_es_mobile["task_id"] : "") . "&id_pt_mobile=" . ($row_pt_mobile ? $row_pt_mobile["task_id"] : "") . "'>Edit</a></td>";
echo "</tr>";
// Increment index counter
$index++;
}
?>
</table>
</body>
</html>