```php prepare("UPDATE visitor_counts SET total_visits = total_visits + 1"); $stmt->execute(); } // Update or insert live visitor $stmt = $pdo->prepare("INSERT INTO live_visitors (session_id) VALUES (:session_id) ON DUPLICATE KEY UPDATE last_activity = CURRENT_TIMESTAMP"); $stmt->execute([':session_id' => $_SESSION['visitor_id']]); // Clean up old live visitors (older than 5 minutes) $stmt = $pdo->prepare("DELETE FROM live_visitors WHERE last_activity < DATE_SUB(NOW(), INTERVAL 5 MINUTE)"); $stmt->execute(); // Get visitor stats $totalVisits = $pdo->query("SELECT total_visits FROM visitor_counts")->fetchColumn(); $liveVisitors = $pdo->query("SELECT COUNT(*) FROM live_visitors")->fetchColumn(); // Get all products $products = $pdo->query("SELECT * FROM products ORDER BY created_at DESC")->fetchAll(PDO::FETCH_ASSOC); ?>
= htmlspecialchars($product['description']) ?>
View on Amazon