How Are These Created - Process Flow

Discussion in 'PHP' started by oo7ml, Sep 22, 2011.

  1. #1
    Hi, i am working on a site at the moment and i am trying to allow customers to build their orders using a "drop down menu / wizard" where each drop drown menu displays content based on the choice in the previous drop down menu...

    As soon as a user chooses an option in the first drop down menu... a second drop down menu appears and the content is based on the users choice in the previous drop down... etc

    I presume this type of function uses ajax and queries the database each time a selection has been made in the drop down menu...

    Question 1: How should you design these in the database... do i need to create a single table for each option in the first drop down menu... or how should you design your product database
    Question 2: If the answer is YES to the first question... i obviously need to store the contents of each drop down menu in the table, but do i also need to store the actual text labels indicating what each drop down is for on the actual order form, as they will also change based on the choice in the previous drop down menu...

    I have spent the last hour trying to draw out what i mean below... these are not products i have on my site... i am just trying to demonstrate what i mean... i hope my diagram gives a better picture of what i am trying to achieve

    [​IMG]

    thanks in advance for your help...
     
    oo7ml, Sep 22, 2011 IP
  2. jevchance

    jevchance Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    2
    Trophy Points:
    0
    #2
    I would imagine you would have a table for ProductType, a table for AdditionalSelections, and a table for AdditionalSelectionOptions.

    ProductTypes
    id
    label
    form_value

    AdditionalSelections
    id
    parent_id
    label

    AdditionalSelectionOptions
    id
    menu_id
    label
    form_value

    So your html will have a select menu that gets its options populated with the rows from ProductTypes. Upon selection of an item, Javascript will grab the value (taken from form_value), and query a script using Ajax. That script will return code. That code will be a select menu will be taken from AdditionalSelections, where 'parent_id' = 'id' from ProductTypes. The options will be populated from AdditionalSelectionOptions, where 'menu_id' = 'id' from AdditionalSelections. It will continue this logic until it hits the bottom of the tree, i.e. 'parent_id' is null.

    Hope this helps.
     
    jevchance, Sep 22, 2011 IP