Fluffy654 Posted September 15, 2008 Share Posted September 15, 2008 I'm trying to create a menu which can be dynamically resorted. I need two categories, customers and items, and I need to be able to sort the menu in terms of each category. For example, I could have the following information Customer A buys items 1, 2 and 3 Customer B buys items 1, 3, and 4 Customer C buys items 2, 3 Then the menu would have a customer 'sorting' that looks like this: Customer A Item 1 Item 2 Item 3 Customer B Item 1 Item 3 Item 4 Customer C Item 2 Item 3 and it would also have an item 'sorting' that looks like this Item 1 Customer A Customer B Item 2 Customer B Customer C Item 3 Customer A Customer B Customer C Item 4 Customer C Currently I have a database that is structured like this: Customer Item Customer AItem 1 Customer AItem 2 and so on but I can't figure out how to write the php so that I can grab Customer A and then each of their items followed by Customer B e.t.c. and then also grab Item 1 and then each of its customer's followed by item 2 e.t.c. I've tried using a while loop but that keeps repeating Customer A for each of Customer A's items when I only want Customer A repeated once, for the top level menu button. However, I do want it repeated when the list is resorted in terms of items (i.e. under each relevant item). Is what I want possible? I have seen it done elsewhere (such as the delicious bookmarks system where you can see all the tags related to another tag sorted in terms of every tag). However, I'm pretty sure that my problem is not in my php but rather in the way in which I am structuring my database hence why I am posting this here and not in the php forum. Thanks very much for any help you can provide Quote Link to comment Share on other sites More sharing options...
Fluffy654 Posted September 19, 2008 Author Share Posted September 19, 2008 I managed to find a solution for this issue and thought I would post it just in case anybody else would find it useful. Basically, I just used the GROUP CONCAT command to turn the item or customer list into a separated list and then specified the separator as anchor tags. Then I just used a single php while function in order to create the resortable, nested menu. If anybody is trying to create this effect and wants some help, please feel free to email me at rupert654 at gmail dot com. Quote Link to comment 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.