prepare('SELECT COUNT(*) AS total FROM accounts a ' . $where); if ($search) $stmt->bindParam('search', $param3, PDO::PARAM_STR); $stmt->execute(); $accounts_total = $stmt->fetchColumn(); // SQL query to get all products from the "products" table $stmt = $pdo->prepare('SELECT a.*, count(t.id) AS orders FROM accounts a LEFT JOIN transactions t ON t.account_id = a.id ' . $where . ' GROUP BY a.id, a.email, a.password, a.role, a.first_name, a.last_name, a.address_street, a.address_city, a.address_state, a.address_zip, a.address_country, a.registered ORDER BY ' . $order_by . ' ' . $order . ' LIMIT :start_results,:num_results'); // Bind params $stmt->bindParam('start_results', $param1, PDO::PARAM_INT); $stmt->bindParam('num_results', $param2, PDO::PARAM_INT); if ($search) $stmt->bindParam('search', $param3, PDO::PARAM_STR); $stmt->execute(); // Retrieve query results $accounts = $stmt->fetchAll(PDO::FETCH_ASSOC); // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { $success_msg = 'Account created successfully!'; } if ($_GET['success_msg'] == 2) { $success_msg = 'Account updated successfully!'; } if ($_GET['success_msg'] == 3) { $success_msg = 'Account deleted successfully!'; } } // Determine the URL $url = 'index.php?page=accounts&search=' . $search; ?> =template_admin_header('Accounts', 'accounts', 'view')?>
View, create, and edit accounts.
=$success_msg?>
| # | Name | Address | Role | Orders Placed | Registered Date | Actions | |
| There are no accounts | |||||||
| =$account['id']?> | =htmlspecialchars($account['email'], ENT_QUOTES)?> | =htmlspecialchars($account['first_name'], ENT_QUOTES)?> =htmlspecialchars($account['last_name'], ENT_QUOTES)?> | =htmlspecialchars($account['address_street'], ENT_QUOTES)?>=$account['address_street']?', ':''?> =htmlspecialchars($account['address_city'], ENT_QUOTES)?>=$account['address_city']?', ':''?> =htmlspecialchars($account['address_state'], ENT_QUOTES)?>=$account['address_state']?', ':''?> =htmlspecialchars($account['address_zip'], ENT_QUOTES)?>=$account['address_zip']?', ':''?> =htmlspecialchars($account['address_country'], ENT_QUOTES)?> | =$account['role']?> | =number_format($account['orders'])?> | =date('F j, Y', strtotime($account['registered']))?> | Edit |