you would nee to create a joined query to return the order information form both the orders and order details:
for example:
SELECT orders., orderdetails.*
FROM orders
INNER JOIN orederdetails
ON orders.orderID = orderdetails.orderID
WHERE orders.orderID = 1
you could then use this recordset to create the invoice,
this is very similar to creating an order history, see the order history tutorial on the eCart support page for details.