select category phpwebcommerce help !

Hi there,is me again …i’m following a tutorial from this site http://www.phpwebcommerce.com/index.php I just want to learn it & set up a simple store from this tutorial. My problem is, in the admin section when I try to add a new product the combo box doesn’t allow me to select the category. It is listing the category, but it isn’t allowing me to select it, if i cant select the category the whole product page won’t be save.

Below is the code:
[php]
/*
Generate combo box options containing the categories we have.
if $catId is set then that category is selected
*/
function buildCategoryOptions($catId = 0)
{
$sql = “SELECT cat_id, cat_parent_id, cat_name
FROM tbl_category
ORDER BY cat_id”;
$result = dbQuery($sql) or die('Cannot get Product. ’ . mysql_error());

$categories = array();  
while($row = dbFetchArray($result)) {  
    list($id, $parentId, $name) = $row;  
      
    if ($parentId == 0) {  
        // we create a new array for each top level categories  
        $categories[$id] = array('name' => $name, 'children' => array());  
    } else {  
        // the child categories are put int the parent category's array  
        $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name);      
    }  
}      
  
// build combo box options  
$list = '';  
foreach ($categories as $key => $value) {  
    $name     = $value['name'];  
    $children = $value['children'];  
      
    $list .= "<optgroup label=\"$name\">";   
      
    foreach ($children as $child) {  
        $list .= "<option value=\"{$child['id']}\"";  
        if ($child['id'] == $catId) {  
            $list.= " selected";  
        }  
          
        $list .= ">{$child['name']}</option>\r\n";  
    }  
      
    $list .= "</optgroup>";  
}  
  
return $list;  

}
[/php]

Thank you in advance. :wink:

anyone know how to solve this problem ? :-[
i have been searching books & google…cant solve it. There is suggestion by doing this:
[php]

Soda Cola Tea Coffee

[/php]

but this method can only select subcategory…and even the subcategory can be select , when i click on save…it show errors :’(

Sponsor our Newsletter | Privacy Policy | Terms of Service