|
Posted by steve on 09/28/79 11:20
i'd start by re-thinking your db structure. it is not a good idea to mingle
your schema with your application...i.e. storing a table name as a reference
point for where specific data is stored. even though it will work, it will
not allow you to scale or change your schema down the road. second, you need
to understand his business. his output is *a* single menu that has
*categories* of menu items. the only time you will have alternate menus
would be for beverages (wine, beer, etc.), desserts, entrees.
all menu items can be stored in this basic fashion:
menuItems:
id
itemName
itemDescription
itemMenu
itemCategory
itemPrice
displayItem
displayOrder
your menus table would look like:
id
menuName
menuDescription
you would then create a category table:
id
categoryName
categoryDescription
displayCategory
displayOrder
you can figure out how the references work for the above schema as they
relate to the menu items table. your menu table would represent beverage,
entree, desserts, etc. your category table would represent soups,
specialties, healthy choices, sea food, etc.
this allows you to select menu data in the same fashion no matter what menu
is to be displayed. finally, all that is left is for you to do is present
the html.
i would generate all the html elements *regardless* of whether each section
had data in it or not. present the menu to the manager as it would display
for the customer...except put a check box next to each category *and* item
(if selected, then the item or category will be displayed to the customer).
also on the manager version of the menu, give them a chance to enter a
category and/or item directly on them menu...you'd already know the menu,
category, and display order of the category and items being entered...you'd
just be collecting the name/description.
as for outputting the customer's menu...i'd use div and span tags as it is
easier to move them around into columns and *way* easier to *not* display
them when they're content is blank. consider outputting every thing on a
particular menu regardless of whether a category has items or not. you can
either skip generating any categorical output as you come across the "no
items" case or, at the end of the generation, use javascript to enum your
div/spans and set its display to:
<your enum variable "el"> el.style.display = el.innerHTML = '' ? 'none' :
'block';
makes your code pretty simple to maintain and scale.
i hope i understood your delima and described an adequate approach to
resolving it.
[Back to original message]
|