prepare("SELECT points, tier FROM user_rewards WHERE user_id = ?"); $stmt->execute([$user_id]); $result = $stmt->fetch(); if ($result) { $points = $result['points']; $tier = $result['tier']; } else { // If user has no entry, create one $insert_stmt = $pdo->prepare("INSERT INTO user_rewards (user_id, points, tier) VALUES (?, ?, ?)"); $insert_stmt->execute([$user_id, 0, 'Bronze']); } $history_stmt = $pdo->prepare("SELECT points_change, reason, created_at FROM reward_history WHERE user_id = ? ORDER BY created_at DESC LIMIT 10"); $history_stmt->execute([$user_id]); $history = $history_stmt->fetchAll(); } catch (PDOException $e) { // Handle database errors error_log($e->getMessage()); // You might want to show a generic error message to the user } include 'header.php'; ?>
Welcome to the MajuroEats Rewards Program! Here you can see your points, your tier, and the rewards you can claim.
You have points.
You are in the tier.
| Date | Reason | Points |
|---|---|---|