Fixes html/css formatting

main
Yasen Pramatarov 2024-07-05 12:13:09 +03:00
parent 308c92af2c
commit e499ef083e
2 changed files with 51 additions and 36 deletions

View File

@ -77,43 +77,46 @@ if (isset($conference_id)) {
}
// display the result
echo "<div class=\"results\">\n";
echo "Conferences with ID matching \"<strong>$conference_id</strong>\"";
if ($time_range_specified) {
echo " for the time period <strong>$from_time - $until_time</strong>";
}
echo "\n\n";
if (!empty($conferences['records'])) {
echo "\t<table id=\"results\">";
echo "\t\t<tr>";
echo "\t<table>\n";
echo "\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>";
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>";
echo "\t\t</tr>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>";
echo "\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>";
echo "\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>";
echo "\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>";
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>";
echo "\t\t</tr>\n";
}
echo "\t</table>";
echo "\t</table>\n";
} else {
echo '<p>No matching conferences found.</p>';
}
echo "\n</div>\n";
// search and list specific conference ID
@ -154,43 +157,46 @@ if (isset($conference_id)) {
}
// display the result
echo "<div class=\"results\">\n";
echo "Conferences with name matching \"<strong>$conference_name</strong>\"";
if ($time_range_specified) {
echo " for the time period <strong>$from_time - $until_time</strong>";
}
echo "\n\n";
if (!empty($conferences['records'])) {
echo "\t<table id=\"results\">";
echo "\t\t<tr>";
echo "\t<table>\n";
echo "\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>";
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>";
echo "\t\t</tr>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>";
echo "\t\t<tr>\n";
// sometimes $column is empty, we make it '' then
foreach ($row as $key => $column) {
if ($key === 'conference name' && $column === $conference_name) {
echo "\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>";
echo "\t\t\t<td><strong>" . htmlspecialchars($column ?? '') . "</strong></td>\n";
} elseif ($key === 'conference ID') {
echo "\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>";
echo "\t\t\t<td><a href=\"$app_root?page=conferences&id=" . htmlspecialchars($column ?? '') . "\">" . htmlspecialchars($column ?? '') . "</a></td>\n";
} else {
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>";
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>";
echo "\t\t</tr>\n";
}
echo "\t</table>";
echo "\t</table>\n";
} else {
echo '<p>No matching conferences found.</p>';
}
echo "\n</div>\n";
// list of all conferences (default)
@ -230,40 +236,46 @@ if (isset($conference_id)) {
}
// display the result
echo "Conferences for the time period $from_time - $until_time";
echo "<div class=\"results\">\n";
echo "All conferences";
if ($time_range_specified) {
echo " for the time period <strong>$from_time - $until_time</strong>";
}
echo "\n\n";
if (!empty($conferences['records'])) {
echo "\t<table id=\"results\">";
echo "\t\t<tr>";
echo "\t<table>\n";
echo "\t\t<tr>\n";
// table headers
foreach (array_keys($conferences['records'][0]) as $header) {
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>";
echo "\t\t\t<th>" . htmlspecialchars($header) . "</th>\n";
}
echo "\t\t</tr>";
echo "\t\t</tr>\n";
//table rows
foreach ($conferences['records'] as $row) {
echo "\t\t<tr>";
echo "\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>";
echo "\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>";
echo "\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>";
echo "\t\t\t<td>" . htmlspecialchars($column ?? '') . "</td>\n";
}
}
echo "\t\t</tr>";
echo "\t\t</tr>\n";
}
echo "\t</table>";
echo "\t</table>\n";
} else {
echo '<p>No matching conferences found.</p>';
}
echo "\n</div>\n";
}

View File

@ -78,19 +78,22 @@
color: white;
}
#results table {
.results {
padding-bottom: 30px;
}
.results table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
padding-bottom: 30px;
}
#results table, th, td {
.results table, th, td {
border: 1px solid #ddd;
}
#results th, td {
.results th, td {
padding: 8px;
text-align: left;
}
#results th {
.results th {
background-color: #f2f2f2;
}