SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    South Africa
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Mapping product options to inventory items

    Hi,

    Using information contained in a mySQL database, I'm generating drop down menus containing available product option values.

    i.e. 1 Product has 0 or more attributes/options

    To get the names (and id's) of the option classes available, I use the following query:

    SELECT a.id, a.name
    FROM attributes AS a
    INNER JOIN product_attributes AS pa
    ON a.id = pa.a_id
    INNER JOIN products AS p
    ON pa.p_id = p.id
    WHERE p.id = 1

    This would return attribute names/id's for product '1'.

    e.g.:
    ____________
    a1 | Color
    a2 | Size

    Using this data I construct 2 option menus. For each attribute/option class, I use the following statement to retrieve the available attribute values:

    SELECT DISTINCT av.id, av.value
    FROM attribute_values AS av
    INNER JOIN item_attribute_values AS iav
    ON iav.av_id = av.id
    INNER JOIN items AS i
    ON i.id = iav.i_id
    WHERE i.quantity > 0
    AND av.a_id = {the attr. id}

    The output resembles the following:

    PHP Code:
    <form action="/site/order.php" method="post">
    <
    table>
        <
    tr>
            <
    td>Color:</td>
            <
    td>
                <
    select name="001">
                    <
    option value="0001">Black</option>
                    <
    option value="0002">White</option>
                </
    select>
            </
    td>
        </
    tr>
        <
    tr>
            <
    td>Size:</td>
            <
    td>
                <
    select name="002">
                    <
    option value="0003">S</option>
                    <
    option value="0004">M</option>
                    <
    option value="0005">L</option>
                </
    select>
            </
    td>
        </
    tr>
    </
    table>
    </
    form
    Now using the submitted values, I need to identify which item (option value combination), the user wishes to purchase from the item table. (1 product : 1 or M items)

    And ideas as to how I could achieve this?

    TIA.

    (mySQL script attached)
    Attached Files Attached Files


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •