Cleaning up HTML

main
Yasen Pramatarov 2024-07-25 12:24:07 +03:00
parent 6400854316
commit 54678bc329
1 changed files with 34 additions and 22 deletions

View File

@ -80,39 +80,45 @@ echo "</div>\n\n";
echo "</div>\n\n";
// results table
echo "<div class=\"results\">\n";
echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) {
echo "\t<table>\n";
echo "\t\t<tr>\n";
echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
echo "\t\t\t\t<th scope=\"col\">" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
echo "\t\t</thead>\n";
echo "\t\t<tbody>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n";
echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'conference ID' && $column === $conference_id) {
echo "\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
echo "\t\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
} elseif ($key === 'conference name') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
echo "\t\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
}
echo "\t\t</tbody>\n";
echo "\t</table>\n";
} else {
echo '<p>No matching conferences found.</p>';
echo '<p class="m-3">No matching conferences found.</p>';
}
echo "\n</div>\n";
@ -191,39 +197,45 @@ echo "</div>\n\n";
echo "</div>\n\n";
// results table
echo "<div class=\"results\">\n";
echo "<div class=\"mb-5\">\n";
if (!empty($conferences['records'])) {
echo "\t<table>\n";
echo "\t\t<tr>\n";
echo "\t<table class=\"table table-striped table-hover table-bordered\">\n";
echo "\t\t<thead class=\"thead-dark\">\n";
echo "\t\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
echo "\t\t\t\t<th scope=\"col\">" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
echo "\t\t</thead>\n";
echo "\t\t<tbody>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>\n";
echo "\t\t\t<tr>\n";
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'conference ID') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} elseif ($key === 'conference name') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
echo "\t\t\t\t<td><a href=\"$app_root?page=conferences&name=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
echo "\t\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>\n";
echo "\t\t\t</tr>\n";
}
echo "\t\t</tbody>\n";
echo "\t</table>\n";
} else {
echo '<p>No matching conferences found.</p>';
echo '<p class="m-3">No matching conferences found.</p>';
}
echo "\n</div>\n";