mpar612 Posted August 18, 2008 Share Posted August 18, 2008 I have an app where I need to read data from multiple MySQL tables and print them out in a particular format. I have multiple menus in a database. I need to print all Categories, Sub Categories and Items. I have experimented with using a LEFT JOIN, but cannot seem to get all of the data out of the tables and printed properly. I printed all of the pertinent information below. Does anyone have any thoughts on how to make this work properly? Thanks in advance! Database tables: items itemId (key) itemName itemDescription price menu category subCategory (could be '0' if item does not have subCategory) menus menuId (key) menuName menuDescription menuCategories categoryId (key) category menu description menuCategories categoryId (key) category menu description menuSubCategory subCategoryId (key) subCategory menuId categoryId I need it to print in this format: Category itemName, item description, price (if item does not have subCategory) subCategory itemName, item description, price subCategory itemName, item description, price Repeat until all categories, sub categories and items have been printed. Quote Link to comment https://forums.phpfreaks.com/topic/120176-php-and-mysql-query/ Share on other sites More sharing options...
JonnoTheDev Posted August 18, 2008 Share Posted August 18, 2008 You will not get this data from 1 query. You will have to start with the category query then select the sub-categories from the category ID within a loop from the category query Quote Link to comment https://forums.phpfreaks.com/topic/120176-php-and-mysql-query/#findComment-619096 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.