/* ===================== mhFault ========================*/ $goods = get_goods_info($goods_id); //获取商品顶级分类,根据顶级分类选用不同模板 $topCatId = end(get_parent_cats($goods['cat_id'])); $topCatId = $topCatId['cat_id']; switch ($topCatId) { case 174: $goodsDwt = 'goodsMhFault.dwt'; break; default: $goodsDwt = 'goods.dwt'; } //获取商品顶级分类end /*=====================*/ $fault_id = $goods['fault_id']; $smarty->assign('fault_detail', get_fault($fault_id, 'fault_detail')); function get_fault($pid, $table = 'fault_category') { $arr = array(); $sql = "SELECT * FROM" . $GLOBALS['ecs']->table($table) . "WHERE pid in('{$pid}')"; $row = $GLOBALS['db']->getAll($sql); foreach ($row as $key => $result) { $arr[$key]['name'] = $result['name']; $arr[$key]['id'] = $result['id']; $pid2 = $arr[$key]['id']; $sql2 = "SELECT * FROM" . $GLOBALS['ecs']->table($table) . "WHERE pid in({$pid2})"; $row2 = $GLOBALS['db']->getALL($sql2); foreach ($row2 as $key2 => $result2) { $arr[$key]['subMhFault'][$key2]['name'] = $result2['name']; $arr[$key]['subMhFault'][$key2]['id'] = $result2['id']; $arr[$key]['subMhFault'][$key2]['matePrice'] = $result2['matePrice'];
<?php define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; $smarty->assign('fault', get_fault(0)); //顶层故障项目 $smarty->assign('fault_detail', get_fault($_GET['fault_id'], 'fault_detail')); $smarty->assign('fault_name', $_GET['fault_name']); $smarty->assign('fault_id', $_GET['fault_id']); $smarty->assign('diyId', $_GET['diyId']); $smarty->assign('fault_diy', get_fault_diy()); switch ($_GET['act']) { case "": $dwt = "mhFault.htm"; break; case "detail": $dwt = "mhFaultD.htm"; break; case "diy": $dwt = "mhFaultDiy.htm"; break; } $smarty->display($dwt); function get_fault($pid, $table = 'fault_category') { $arr = array(); $sql = "SELECT * FROM" . $GLOBALS['ecs']->table($table) . "WHERE pid in('{$pid}')"; $row = $GLOBALS['db']->getAll($sql); foreach ($row as $key => $result) { $arr[$key]['name'] = $result['name']; $arr[$key]['id'] = $result['id'];