instantcms.ru/blogs/lunyi-blog/ajaks-podbor-goroda-profilja.htmlhttp://instantcms.ru/blogs/lunyi...-profilja.html
Встала задача добавить еще одно поле — "профессия". Создал в базе данных таблицу cms_users_profession с полями id_proff и user_proff. Теперь нужно модифицировать обработчик php:
<?php include(PATH.'/core/cms.php'); $inCore = cmsCore::getInstance(); $inDB = cmsDatabase::getInstance(); $city = $inCore->request('query', 'str'); //Идентификатор главной страны $id_main_country = 1; $sql = "SELECT s.id_city, s.id_region, s.id_country, s.city_name_ru, r.region_name_ru, c.country_name_ru, COUNT( p.id ) AS popule FROM cms_geo_cities s LEFT JOIN cms_user_profiles p ON s.city_name_ru = p.city LEFT JOIN cms_geo_countries c ON s.id_country = c.id_country LEFT JOIN cms_geo_regions r ON s.id_region = r.id_region WHERE city_name_ru LIKE '{$city}%' GROUP BY s.city_name_ru ORDER BY popule DESC , s.city_name_ru ASC"; $res = $inDB->query($sql); if ($inDB->num_rows($res)) { while($ress = $inDB->fetch_assoc($res)){ $suggestions[] = ($ress['popule'] > 10 ? '<b>' : '').$ress['city_name_ru'].($ress['popule'] > 10 ? '</b>' : '').' <i> \ '.$ress['region_name_ru'].($ress['id_country']==$id_main_country ? '' : '<span> \ '.$ress['country_name_ru'].'</span>').'</i>'; $data[] = array('city' => $ress['city_name_ru'], 'id_city' => $ress['id_city'], 'id_region' => $ress['id_region'], 'id_country' => $ress['id_country']); } }