Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Like above, you will probably want to use relational databases. Here is a rough idea below.. "pk"=primary key, "fk" = foreign key. Obviously I am omitting some other important fields</p> <pre><code>tblRestaurant pkRestaurant tblRestaurantTypesItems fkRestaurant fldMenuType fldItem </code></pre> <p>To retrieve your items, you could run a query like this</p> <pre><code>SELECT * FROM tblRestaurant R INNER JOIN tblRestaurantTypesItems RTI ON R.pkRestaurant=RTI.fkRestaurant ORDER BY R.pkRestaurant </code></pre> <p>I haven't tested this query but thats a rough idea</p> <p>This would return a recordset like:</p> <pre><code>|Arbys |Breakfast|EGGS |Arbys |Lunch |Burger |McDonalds|Breakfast|McMuffin |McDonalds|Breakfast|Hashbrown |McDonalds|Breakfast|Coffee |McDonalds|Lunch |Big Mac |McDonalds|Dinner |Fries </code></pre> <p>Or if you want to get more specific</p> <pre><code>SELECT * FROM tblRestaurant R INNER JOIN tblRestaurantTypesItems RTI ON R.pkRestaurant=RTI.fkRestaurant WHERE R.pkRestaurant="McDonalds" AND RTI.fldMenuType="Breakfast" </code></pre> <p>Which would return something along the lines of</p> <pre><code>|McDonalds|Breakfast|McMuffin |McDonalds|Breakfast|Hashbrown |McDonalds|Breakfast|Coffee </code></pre> <p>edit: I realize I strayed of OPs meaning of "menu types" by using breakfast lunch dinner instead of breakfast, burgers, desserts. Would be the same idea. </p> <p>So in PHP if you had an array of $menuTypes() and each type had an array of $items() like you said in your original question, such that $menuTypes['breakfast'] = $breakfastItems(), you could do something like this.. Not the best way to do it but meh</p> <pre><code>$restaurant = "McDonalds" foreach ($menuTypes as $items){ $menuTypeName = key($items); //not sure if key() works on elements of arrays // which are arrays themselves foreach($items as $item){ //Assuming "McDonalds" Is already in tblRestaurant so we don't need to //insert it now $query="INSERT INTO tblRestaurantTypesItems VALUES('".$restaurant."', '".$menuTypeName."', '".$item."')" //execute query } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload