prepare('SELECT COUNT(*) AS total FROM products p ' . $where); if ($search) $stmt->bindParam('search', $param3, PDO::PARAM_STR); $stmt->execute(); $products_total = $stmt->fetchColumn(); // SQL query to get all products from the "products" table $stmt = $pdo->prepare('SELECT p.*, GROUP_CONCAT(m2.full_path) AS imgs FROM products p LEFT JOIN (SELECT pm.id, pm.product_id, m.full_path FROM products_media pm JOIN media m ON m.id = pm.media_id GROUP BY pm.id, pm.product_id, m.full_path) m2 ON m2.product_id = p.id ' . $where . ' GROUP BY p.id, p.name, p.description, p.price, p.rrp, p.quantity, p.date_added, p.weight, p.url_slug, p.status 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 $products = $stmt->fetchAll(PDO::FETCH_ASSOC); // Delete product if (isset($_GET['delete'])) { // Delete the product $stmt = $pdo->prepare('DELETE p, pm, po, pc FROM products p LEFT JOIN products_media pm ON pm.product_id = p.id LEFT JOIN products_options po ON po.product_id = p.id LEFT JOIN products_categories pc ON pc.product_id = p.id WHERE p.id = ?'); $stmt->execute([ $_GET['delete'] ]); // Clear session cart if (isset($_SESSION['cart'])) { unset($_SESSION['cart']); } header('Location: index.php?page=products&success_msg=3'); exit; } // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { $success_msg = 'Product created successfully!'; } if ($_GET['success_msg'] == 2) { $success_msg = 'Product updated successfully!'; } if ($_GET['success_msg'] == 3) { $success_msg = 'Product deleted successfully!'; } } // Determine the URL $url = 'index.php?page=products&search=' . $search . '&status=' . $status . '&quantity=' . $quantity; ?>

Products

View, manage, and search products.

Create Product
Filters
# Productcode Name Price Quantity Images Date Added Status Actions
There are no products
<?=$img?> Edit