views:

241

answers:

1

Hello

i need to refresh combo box (sub category ) related to what i choose in main category combo box , for example if i choose "chicken" in main category , the value of sub category will be "grilled chicken" , " fried chicken " ? how should i do this ?

    <select name="categorylist" id="categorylist">
    <?
    $sql_query= mysql_query("select category_id,category_name, from categories");
    while($fetch= mysql_fetch_array($sql_query)) 
    {   ?>

      <option value= " <? echo "$fetch[category_id];" ?> " selected="selected"><? echo "$fetch[category_name]"; ?> </option>
     <? 
    }
     ?>

what should i put in subcategory ?

+1  A: 

This is often refereed to as a "Dependent" or "Dynamic" drop-down. Try a search for that term and you are likely to find a bunch of examples and explanations.

I posted a rather lengthy explanation a while ago, over here:
http://www.dbforums.com/php/1638255-dynamic-drop-down-selection.html

It uses JavaScript though. But even so, if you don't want that, it should at least give you an idea as to where you could start.

Atli
thank you , i will check it :)
Bader