function getOptPType($sId = '', $parent = 'root') { $ct = new product_type(); $ct->setWhere("parent='" . $parent . "'"); $temp = $ct->getList(); if ($sId == 'root') { $str = '<option value="root" selected >主目錄</option>'; } else { $str = '<option value="root">主目錄</option>'; } foreach ($temp as $key => $val) { if ($val['id'] == $sId) { $str .= '<option value="' . $val['id'] . '" selected > ' . $val['title'] . '</option>'; } else { $str .= '<option value="' . $val['id'] . '" > ' . $val['title'] . '</option>'; } } return $str; }