celextel Posted March 30, 2021 Share Posted March 30, 2021 We are using osCommerce Online Merchant v2.3.4.1. We are trying to make a PHP File for generating Order List based on the Order Status without the use of any Core Files in the Admin Area. The following PHP Code is showing Order List [Products Ordered] in a Split up way: $status = (int)$_GET['status']; $row = -1; $orders_products_query = "SELECT o.orders_id, o.delivery_name, op.products_name, op.products_quantity, p.products_gst FROM orders o, orders_products op, products p WHERE o.orders_id = op.orders_id AND op.products_id = p.products_id AND o.orders_status = $status ORDER BY p.products_gst ASC, op.products_name ASC"; $orders_products_query_result = mysqli_query($connect_db, $orders_products_query); $last_orders_id = ''; while ($orders_products = mysqli_fetch_assoc($orders_products_query_result)) { if ($orders_products['orders_id'] <> $last_orders_id) { $row++; $last_orders_id = $orders_products['orders_id']; echo '<br><h2>'. $orders_products['delivery_name'] .'</h2>'; } echo $orders_products['products_quantity'] . ' x ' . $orders_products['products_name'] . '<br>'; } Result is showing in the following manner: Quote Delivery Name [1] Product [1] Delivery Name [2] Product [1] Product [2] Product [3] Delivery Name [1] Product [2] Delivery Name [2] Product [4] Please help in correcting this PHP Code. Thanks, Lakshmanan Link to comment Share on other sites More sharing options...
celextel Posted March 31, 2021 Author Share Posted March 31, 2021 This has been RESOLVED by the following Code: $status = (int)$_GET['status']; $orders_query = "SELECT orders_id, delivery_name FROM orders WHERE orders_status = '" . (int)$status . "' ORDER BY orders_id DESC"; $orders_query_result = mysqli_query($connect_db, $orders_query); while ($orders = mysqli_fetch_assoc( $orders_query_result)) { $order_id = $orders['orders_id']; echo '<b>' . $orders['delivery_name'] . '</b> | ' . 'Order No. ' . $order_id . '<br>'; $products_query = "SELECT products_quantity, products_name, products_gst FROM orders_products WHERE orders_id = '" . (int)$order_id . "' ORDER BY products_gst ASC, products_name ASC"; $products_query_result = mysqli_query($connect_db, $products_query); while ($products = mysqli_fetch_assoc($products_query_result)) { echo $products['products_quantity'] . ' x ' . $products['products_name'] . '<br>'; } } Lakshmanan Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.