alert('订单不存在或您没有权限查看');history.back();"; exit; } // 获取订单项信息 $sql = "SELECT oi.*, p.ProductName, pc.name as category_name, ps.id as product_spec_id, ps.spec_name, ps.spec_value, oi.specification_id /* 显式获取数据库中的specification_id */ FROM order_items oi LEFT JOIN products p ON oi.product_id = p.id LEFT JOIN product_categories pc ON p.category_id = pc.id LEFT JOIN product_specifications ps ON oi.specification_id = ps.id WHERE oi.order_id = $id"; $itemsResult = mysqli_query($conn, $sql); $orderItems = []; while ($itemRow = mysqli_fetch_assoc($itemsResult)) { // 调试输出 error_log("订单项数据: " . print_r($itemRow, true)); $orderItems[] = $itemRow; } } else { echo ""; exit; } ?>