scc24php/faculty/_home.php

53 lines
2.4 KiB
PHP

<?php
require('.hta_config/env.php');
require('./.hta_header.php');
$noticeType = $_GET['type'];
if($noticeType === 'notice'){
$noticeHead = 'General Notice';
} elseif($noticeType === 'tender'){
$noticeHead = 'Tender Notice';
}
?>
<div class="container">
<h2 style="text-align: center; margin: 20px 0px;"><?php echo $noticeHead ?></h2>
<table style="border-collapse: collapse; width: 100%; ">
<thead>
<tr>
<th style="border: 1px solid #6b6245; padding: 8px; text-align: left;">Sl No.</th>
<th style="border: 1px solid #6b6245; padding: 8px; text-align: left;">Title</th>
<th style="border: 1px solid #6b6245; padding: 8px; text-align: left;">Action</th>
</tr>
</thead>
<tbody>
<?php
try {
$conn = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT * FROM `scc24` WHERE `type` = :type ORDER BY (`date_created` = CURDATE()) DESC, `date_created` DESC");
$stmt->bindParam(':type', $noticeType, PDO::PARAM_STR);
$stmt->execute();
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
$serialNumber = 1;
foreach ($content as $notice) {
echo '<tr>
<td style="border: 1px solid #6b6245; padding: 8px;">' . $serialNumber . '</td>
<td style="border: 1px solid #6b6245; padding: 8px;">' . htmlspecialchars($notice['title']) . '</td>
<td style="border: 1px solid #6b6245; padding: 8px; text-align: center;">
<a href="/notice/'.$notice['slug'].'.html">View</a>
<a href="#"></a>
</td>
</tr>';
$serialNumber++;
}
echo '';
} catch (PDOException $e) {
echo "<p class='text-danger'>Error: " . htmlspecialchars($e->getMessage()) . "</p>";
}
?>
</tbody>
</table>
</div>
<?php
require('./.hta_footer.php');
?>