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

View File

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