In general, when adding a product to the store, the user selects a section.
echo 'Раздел: <select name="cat">'; $res = mysql_query('SELECT * FROM `shop_cat` ORDER BY `realid`;'); while($row = mysql_fetch_assoc($res)) { echo '<option value="'.$row['id'].'">'.$row['name'].'</option>'; } echo '</select><br/>';
When choosing a valid first section, you need to make it appear below the subsection with the categories of the first section. If the second - then the subsection, respectively, with the categories of the second section.