Answer the question
In order to leave comments, you need to log in
How to enter address info?
A typical solution is required for a typical task: enter 3 upper levels of the address: country - region - city (or settlement). HTML + PHP. DB structure? Reference codes of regions, cities where to get (at least for Russia, better - for many countries)?
Thank you!
Answer the question
In order to leave comments, you need to log in
habrahabr.ru/post/204840
or
manually: 1 database of cities ( www.geonames.org/) , three requests.
1) select a country
2) use Ajax to load a request for the regions of the country,
3) repeat the feint with Ajax, but already load the settlements of the selected region.
In general, the database structure is as follows:
CREATE TABLE `points` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`parent` int(11) DEFAULT NULL COMMENT 'Родитель',
`name` varchar(128) NOT NULL COMMENT 'Название',
PRIMARY KEY (`id`),
KEY `parent` (`parent`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
INSERT INTO `points` (`parent` ,`name`) VALUES (NULL, 'Россия');
-- 'Россия': ID = 1
INSERT INTO `points` (`parent` ,`name`) VALUES (1, 'Хабаровский край');
-- 'Хабаровский край': ID = 1234
INSERT INTO `points` (`parent` ,`name`) VALUES (1234, 'Хабаровск');
CREATE TABLE `points` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
`left_key` int(11) DEFAULT '0' COMMENT 'Левый ключ',
`right_key` int(11) DEFAULT '0' COMMENT 'Правый ключ',
`parent` int(11) DEFAULT NULL COMMENT 'Родитель',
`level` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Уровень вложенности',
`name` varchar(128) NOT NULL COMMENT 'Название',
PRIMARY KEY (`id`),
KEY `left_key` (`left_key`),
KEY `right_key` (`right_key`),
KEY `parent` (`parent`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question