Jump to content

PHP and MySQL Query


mpar612

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.