ballhogjoni Posted November 8, 2008 Share Posted November 8, 2008 I have 5 categories and I have 5-10 items in each category. How would I print the categories and the items in each category vertically like: category item item item item category item item item category item item etc... my code $aOffers = $oZend_Db_Adapter_Pdo_Mysql->fetchAll('SELECT o.*,og.name FROM Offer as o LEFT JOIN Offer_group as og ON o.offer_group_id = og.group_id'); //returns an array foreach( $aOffers as $key => $item ){ echo '<tr><td>'.$key.'</td></tr>'; } The table Offer holds the items and the table Offer_group holds the category. There is an fk the links these to tables as stated in the ON clause Link to comment https://forums.phpfreaks.com/topic/131951-solved-determining-query-and-code-question/ Share on other sites More sharing options...
Barand Posted November 8, 2008 Share Posted November 8, 2008 first you need to change GROUP BY to ORDER BY http://www.phpfreaks.com/forums/index.php/topic,214328.msg978906.html#msg978906 Link to comment https://forums.phpfreaks.com/topic/131951-solved-determining-query-and-code-question/#findComment-685628 Share on other sites More sharing options...
ballhogjoni Posted November 8, 2008 Author Share Posted November 8, 2008 I am not grouping or ordering anything Link to comment https://forums.phpfreaks.com/topic/131951-solved-determining-query-and-code-question/#findComment-685635 Share on other sites More sharing options...
Barand Posted November 8, 2008 Share Posted November 8, 2008 Sorry, mis-read it. Add ORDER BY og.name, then use the link I provided Link to comment https://forums.phpfreaks.com/topic/131951-solved-determining-query-and-code-question/#findComment-685654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.