queryString; } ?>
        DEBUG INFORMATION:
        GET Parameters: 
        Current Category ID: 
        Current Category Name: 
        Current Links Count: 
        Raw Query String: 
        SQL Query for links: 
    
query("SELECT * FROM categories WHERE visibility = 1 ORDER BY display_order ASC, name ASC"); $categories = $stmt->fetchAll(); // Determine the current category $current_category_id = null; $current_category_name = 'All Categories'; if (isset($_GET['category']) && filter_var($_GET['category'], FILTER_VALIDATE_INT)) { $category_id_from_get = (int)$_GET['category']; $stmt = $pdo->prepare("SELECT id, name FROM categories WHERE id = ? AND visibility = 1"); $stmt->execute([$category_id_from_get]); $cat = $stmt->fetch(); if ($cat) { $current_category_id = $cat['id']; $current_category_name = $cat['name']; } } // Fetch links for the current category $link_stmt = null; if ($current_category_id) { $link_stmt = $pdo->prepare( "SELECT l.*, s.name as subcategory_name FROM links l " . "JOIN subcategories s ON l.subcategory_id = s.id " . "WHERE s.category_id = ? AND l.status = \'approved\' ORDER BY s.name ASC, l.created_at DESC" ); $link_stmt->execute([$current_category_id]); } else { $link_stmt = $pdo->query( "SELECT l.*, s.name as subcategory_name, c.name as category_name " . "FROM links l " . "JOIN subcategories s ON l.subcategory_id = s.id " . "JOIN categories c ON s.category_id = c.id " . "WHERE l.status = 'approved' " . "ORDER BY c.name ASC, s.name ASC, l.created_at DESC" ); } $current_links = $link_stmt->fetchAll(); ?>

No links found in this category yet.

' . htmlspecialchars($current_category_for_display) . ''; $current_subcategory = null; // Reset subcategory when category changes } if ($link['subcategory_name'] !== $current_subcategory) { $current_subcategory = $link['subcategory_name']; echo '

' . htmlspecialchars($current_subcategory) . '

'; } ?>