<?php
require_once '../config/database.php';
require_once '../includes/functions.php';
$pageTitle = 'Ads';
include 'header.php';

$conn = getConnection();
$ads = $conn->query("SELECT * FROM ads WHERE status='active' ORDER BY created_at DESC");
?>
<div class="container">
    <div class="card">
        <h3>📺 Watch Ads & Earn</h3>
        <div class="row">
            <?php while ($ad = $ads->fetch_assoc()): ?>
            <div class="col-md-6">
                <div class="card gradient-pink" style="color:white">
                    <h4><?php echo htmlspecialchars($ad['title']); ?></h4>
                    <p><?php echo htmlspecialchars($ad['content']); ?></p>
                    <div style="font-size:24px;font-weight:700">Ksh <?php echo number_format($ad['reward'], 2); ?></div>
                    <button class="btn btn-success" style="margin-top:10px">View Ad</button>
                </div>
            </div>
            <?php endwhile; ?>
        </div>
    </div>
</div>
<?php include 'footer.php'; ?>
