query("SHOW TABLES LIKE 'assets'"); if ($result->rowCount() == 0) { $sql = file_get_contents('db/migrations/001_create_assets_table.sql'); $pdo->exec($sql); } $stmt = $pdo->query('SELECT * FROM assets ORDER BY created_at DESC'); return $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { // In a real app, you'd log this error and show a user-friendly message. // For this initial setup, we'll just display the error. return ['error' => 'Database error: ' . $e->getMessage()]; } } $assets = get_assets(); function getStatusClass($status) { switch (strtolower($status)) { case 'in service': return 'status-in-service'; case 'under repair': return 'status-under-repair'; case 'retired': return 'status-retired'; default: return ''; } } ?>