Spaces:
Sleeping
Sleeping
| // Include database connection | |
| require_once 'includes/db_connect.php'; | |
| require_once 'includes/domain_utils.php'; | |
| require_once 'includes/auth_check.php'; | |
| // Get domain descriptions | |
| $domainDescriptions = getDomainDescriptions($conn); | |
| // Get all domain tables and sort them numerically | |
| $domainTables = getDomainTables($conn); | |
| usort($domainTables, function($a, $b) { | |
| $numA = intval(preg_replace('/[^0-9]/', '', $a)); | |
| $numB = intval(preg_replace('/[^0-9]/', '', $b)); | |
| return $numA - $numB; | |
| }); | |
| // Include header | |
| include 'includes/header.php'; | |
| <div class="row mb-4"> | |
| <div class="col-md-12"> | |
| <nav aria-label="breadcrumb"> | |
| <ol class="breadcrumb"> | |
| <li class="breadcrumb-item"><a href="index.php">Home</a></li> | |
| <li class="breadcrumb-item active">Domains</li> | |
| </ol> | |
| </nav> | |
| <div class="d-flex justify-content-between align-items-center"> | |
| <h2><i class="fas fa-layer-group me-2"></i> Project Domains</h2> | |
| </div> | |
| <p class="lead">Browse project domains to find projects in different areas of interest.</p> | |
| </div> | |
| </div> | |
| <div class="row"> | |
| <?php foreach ($domainTables as $domainTable): | |
| // Extract domain number from table name | |
| preg_match('/domain_(\d+)/', $domainTable, $matches); | |
| if (isset($matches[1])): | |
| $domainNumber = $matches[1]; | |
| // Get project count for this domain | |
| $countQuery = "SELECT COUNT(*) as count FROM $domainTable"; | |
| $countResult = $conn->query($countQuery); | |
| $projectCount = $countResult->fetch_assoc()['count']; | |
| // Get domain description | |
| $domainDescription = isset($domainDescriptions[$domainNumber]) ? $domainDescriptions[$domainNumber] : "Domain $domainNumber"; | |
| ?> | |
| <div class="col-md-6 col-lg-4 mb-4"> | |
| <div class="card h-100 shadow-sm domain-card"> | |
| <div class="card-header bg-primary text-white"> | |
| <h5 class="mb-0">Domain <?php echo htmlspecialchars($domainNumber); ?></h5> | |
| </div> | |
| <div class="card-body"> | |
| <p class="card-text"><?php echo htmlspecialchars($domainDescription); ?></p> | |
| <div class="d-flex justify-content-between align-items-end mt-3"> | |
| <span class="badge bg-secondary fs-6"> | |
| <i class="fas fa-clipboard-list me-1"></i> <?php echo $projectCount; ?> Project<?php echo $projectCount != 1 ? 's' : ''; ?> | |
| </span> | |
| <div> | |
| <a href="domain_projects.php?domain=<?php echo urlencode($domainNumber); ?>" class="btn btn-outline-primary"> | |
| <i class="fas fa-eye me-1"></i> View Projects | |
| </a> | |
| <?php if ($is_faculty): ?> | |
| <a href="project_add.php?domain=<?php echo urlencode($domainNumber); ?>" class="btn btn-outline-success"> | |
| <i class="fas fa-plus-circle me-1"></i> Add Project | |
| </a> | |
| <?php endif; ?> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| endif; | |
| endforeach; | |
| if (count($domainTables) == 0): | |
| ?> | |
| <div class="col-md-12"> | |
| <div class="alert alert-info"> | |
| <i class="fas fa-info-circle me-2"></i> No domains found in the database. | |
| </div> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| <?php | |
| // Include footer | |
| include 'includes/footer.php'; | |
| // Close connection | |
| $conn->close(); | |
| ?> |