Results 1 to 3 of 3

Thread: About dropdown combo

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    30

    About dropdown combo

    hi all..please let me know..

    I have 2 tables..category(cat_id,cat_code,cat_desc) and item(item_id,item_code,item_desc,cat_code).One category have many items.
    There are 2 drop down combos in my form.for category and item.if I select the category, just items under category will listed in item's drop down combo...
    Here is my codes:

    for category:
    PHP Code:
    <td><select name="cat_code">
                <?
                    $sqlst = mysql_query("SELECT cat_code,cat_desc FROM category  ORDER BY cat_desc");
                    while($cat = mysql_fetch_array($sqlst)){ ?>
                    <option  value="<? echo $cat['cat_code'] ?>"><? echo $cat['cat_desc'] ?>
                    </option>
                    <? } ?>
                  </select></td>
    For Item:I dont know how and where to assign a variable for $cat_code
    PHP Code:
    <td><select name="item_code">
                <?
                    $sqlst = mysql_query("SELECT item_code,item_desc FROM item WHERE cat_code='$cat_code'");
                    while($item = mysql_fetch_array($sqlst)){ ?>
                    <option  value="<? echo $item['item_code'] ?>"><? echo $item['item_desc'] ?>
                    </option>
                    <? } ?>
                  </select></td>
    Thnks in advance
    Last edited by saraa; Oct 30th, 2006 at 10:17 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width