Welcome, User!
Wallet Balance
R1,250.75
Available Funds
Quick Actions
Recent Transactions
exec("CREATE TABLE IF NOT EXISTS transactions ( id INT AUTO_INCREMENT PRIMARY KEY, description VARCHAR(255) NOT NULL, amount DECIMAL(10, 2) NOT NULL, type VARCHAR(50) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP )"); // Clear existing transactions and insert sample data for demonstration $pdo->exec("TRUNCATE TABLE transactions"); $transactions = [ ['Payment to Shoprite', -120.50, 'Merchant Payment'], ['Received from J. Doe', 250.00, 'P2P Transfer'], ['Airtime Purchase (MTN)', -50.00, 'Bill Payment'], ['Payment to Pick n Pay', -340.75, 'Merchant Payment'], ['Received from A. Smith', 500.00, 'P2P Transfer'], ]; $stmt = $pdo->prepare("INSERT INTO transactions (description, amount, type) VALUES (?, ?, ?)"); foreach ($transactions as $tx) { $stmt->execute($tx); } // Fetch transactions $stmt = $pdo->query("SELECT description, amount, type, created_at FROM transactions ORDER BY created_at DESC"); $transactions = $stmt->fetchAll(); if (count($transactions) > 0) { echo '- ';
foreach ($transactions as $tx) {
$amount_class = $tx['amount'] > 0 ? 'text-success' : 'text-danger';
$icon = $tx['amount'] > 0 ? 'bi-arrow-down-circle-fill' : 'bi-arrow-up-circle-fill';
$amount_prefix = $tx['amount'] > 0 ? '+' : '-';
$formatted_amount = 'R' . number_format(abs($tx['amount']), 2);
echo '
- ';
echo ''; echo ''; echo '' . htmlspecialchars($tx['description']) . ''; echo '' . htmlspecialchars($tx['type']) . ''; echo ''; echo '' . $amount_prefix . ' ' . $formatted_amount . ''; echo ' ';
}
echo '
No recent transactions.
'; } } catch (PDOException $e) { echo 'Database error: ' . htmlspecialchars($e->getMessage()) . '
'; } ?>