Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/120176-php-and-mysql-query/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.