function insert_all_brand_info() { $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, b.brand_desc, replace(b.site_url, 'http://', '') as site_url, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, " . $GLOBALS['ecs']->table('goods') . " AS g " . "WHERE g.brand_id = b.brand_id {$children} AND is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY replace(b.site_url, 'http://', '') ASC"; $brand_array = $GLOBALS['db']->getall($sql); $brand_list = array(); for ($i = 0; $i < count($brand_array); $i++) { $l = get_first_char($brand_array[$i]['site_url']); $brand_list[$l][$brand_array[$i]['brand_id']] = $brand_array[$i]['brand_id'] . "-" . $brand_array[$i]['brand_name'] . "-" . $brand_array[$i]['site_url'] . "-" . $brand_array[$i]['brand_logo']; } $show = ''; foreach ($brand_list as $row => $idx) { $show .= '<dl class="item"> <dt><a name="' . $row . '">' . $row . '</a></dt> <dd>'; foreach ($idx as $row2 => $idx2) { $idx2 = explode('-', $idx2); $show .= '<a href="brand.php?id=' . $idx2[0] . '">' . $idx2[1] . '</a>'; } $show .= '</dd> </dl>'; } return $show; }
function get_all_brand() { $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, b.brand_desc, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag FROM " . $GLOBALS['ecs']->table("brand") . "AS b, " . $GLOBALS['ecs']->table("goods") . " AS g " . ("WHERE g.brand_id = b.brand_id " . $children . " AND is_show = 1 ") . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY CONVERT( brand_name USING gbk ) COLLATE gbk_chinese_ci ASC"; $brand_array = $GLOBALS['db']->getall($sql); $brand_list = array(); $i = 0; for (; $i < count($brand_array); ++$i) { $l = get_first_char($brand_array[$i]['brand_name']); $brand_list[$l][$brand_array[$i]['brand_id']] = $brand_array[$i]['brand_name'] . "-" . $brand_array[$i]['brand_id']; } $show = ""; foreach ($brand_list as $row => $idx) { $show .= "<dl>\r\n\t\t\t\t\t<dt>" . $row . "</dt>\r\n\t\t\t\t <dd>\r\n\t\t\t\t <ul>"; foreach ($idx as $row2 => $idx2) { $idx2 = explode("-", $idx2); $show .= "<li> <a href='brand.php?id=" . $idx2['1'] . "' target='_blank'>{$idx2['0']}</a> </li>"; } $show .= "</ul>\r\n\t\t\t\t </dd>\r\n\t\t\t\t</dl>"; } return $show; }