Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP/ MySQL Split by group

Featured Replies

I am creating a pub site with food/ drink menu's.

 

I am trying to make it as efficient as possible. I have it set up roughly like this:

 

SELECT * FROM MenuList

 

FOR EACH MenuList RESULT {

 

<li>

 

SELECT * FROM MenuCategory

 

Category_1

 

SELECT * FROM MenuItem WHERE MenuList = MenuListID AND MenuCategory = MenuCategoryID

 

FOR MenuItem {

 

SHOW MENU ITEM DETAILS

 

}

 

Category_2

 

SELECT * FROM MenuItem WHERE MenuList = MenuListID AND MenuCatagory = MenuCatagoryID

 

FOR MenuItem {

 

SHOW MENU ITEM DETAILS

 

}

 

Category_3

 

SELECT * FROM MenuItem WHERE MenuList = MenuListID AND MenuCatagory = MenuCatagoryID

 

FOR MenuItem {

 

SHOW MENU ITEM DETAILS

 

}

 

</li>

 

}

 

 

 

 

This will show like this:

 

 

 

 

Main Menu (MenuList)

 

Starter (MenuCategory)

 

Item1 :: Description1 :: Price1 (MenuItem)

 

Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem)

Main (MenuCategory)

Item1 :: Description1 :: Price1 (MenuItem)

 

Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem)

Dessert (MenuCategory)

Item1 :: Description1 :: Price1 (MenuItem)

 

Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem)

Special Menu (MenuList)

 

Starter (MenuCategory)

 

Item1 :: Description1 :: Price1 (MenuItem)

 

Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem)

Main (MenuCategory)

Item1 :: Description1 :: Price1 (MenuItem)

 

Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem)

Dessert (MenuCategory)

Item1 :: Description1 :: Price1 (MenuItem)

 

Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem)

My only issue is having a select statement for each item within the category. As I have them within <li> elements for the whole menu list's, I'm using jQuery to hide all <li> apart from the first. As it is self manageable, the client can add as many menus as possible. So, the risk is, if they create 10 menus, but with 6 categories & 50 items within each Category, the SELECT Statement within each Category could add up to 1000+ sql statements for the one page.

 

My basic question after all that:

Is there a way to split the sql statement by categories and show items via each split.

 

If this makes sense, please could you help.

 

Like I said, it works well but I don't want performance to be an issue for the client.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.