So, basically I need to list multiple orders on a page, along with their line items. There is an orders table, and a line items table - basic set up. This is the way I'm doing it now, and I'm wondering if there's not a more efficient way to do this. I've simplified the code a bit for my question here, but it gets the point across
$order = $db->getAssoc(SELECT * FROM orders);
foreach($order as $k=>$v) {
$line_item = $db->getAssoc("SELECT * FROM order_line_item WHERE order_id = $k");
$order[$k]['shipping'] = $line_item;
}
And then I just operate on the order array to get the info. Is there a better way to do this?