For more information about how to use PHP to read databases, see my database data: --- & nbsp; TABLE structure & nbsp; '3G _ district '-- CREATE & nbsp; TABLE & nbsp; IF & nbsp; NOT & nbsp; EXISTS & nbsp; '3G _ district '& nbsp; (& nbsp; 'd _ id' & nbsp; mediumint (8) & nbs PHP read Database Display problems
My database data is as follows :-
-- Table structure '3G _ district'
--
Create table if not exists '3G _ district '(
'D _ id' mediumint (8) unsigned not null AUTO_INCREMENT,
'D _ name' char (255) not null,
'D _ level 'tinyint (4) unsigned not null default '0 ',
'D _ pid 'mediumint (8) unsigned not null default '0 ',
'D _ list 'smallint (6) not null default '0 ',
Primary key ('d _ id '),
KEY 'upid '('d _ pid', 'd _ list ')
) ENGINE = InnoDB default charset = utf8 AUTO_INCREMENT = 45052;
--
-- The data in the table is '3G _ district'
--
Insert into '3G _ district '('d _ id', 'd _ name', 'd _ level', 'd _ pid, 'd _ list') VALUES
(1, 'Beijing', 1, 0, 0 ),
(2, 'Tianjin city ', 1, 0, 0 ),
(3, 'hebei province ', 1, 0, 0 ),
(4, 'Shanxi E', 1, 0, 0 ),
(5, 'Inner Mongolia ', 1, 0, 0 ),
(6, 'Liaoning province ', 1, 0, 0 ),
(7, 'Jilin province ', 1, 0, 0 ),
(8, 'heilongjiang province ', 1, 0, 0 ),
(9, 'Shanghai', 1, 0, 0 ),
(10, 'Jiangsu province ', 1, 0, 0 ),
(11, 'Zhejiang province ', 1, 0, 0 ),
(12, 'Anhui province ', 1, 0, 0 ),
(13, 'Fujian province ', 1, 0, 0 ),
(14, 'jiangxi province ', 1, 0, 0 ),
(15, 'Shandong province ', 1, 0, 0 ),
(16, 'Henan province ', 1, 0, 0 ),
(17, 'hubei province ', 1, 0, 0 ),
(18, 'hunan province ', 1, 0, 0 ),
(19, 'Guangdong province ', 1, 0, 0 ),
(20, 'Guangxi Zhuang autonomous region ', 1, 0, 0 ),
(21, 'Hainan ', 1, 0, 0 ),
(22, 'Chongqing ', 1, 0, 0 ),
(23, 'Sichuan province, 1, 0, 0 ),
My conn. php file is as follows:
$ Mysql_server_name = "localhost"; // database server name
$ Mysql_username = "root"; // User name used to connect to the database
$ Mysql_password = ""; // connection password
$ Mysql_database = "teafea"; // database name
// Connect to the database
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// Use utf8 encoding
Mysql_query ("set names 'utf8 '");
// SQL statement used to extract information from the table
$ Str = "select d_id, d_name from region _district ";
// Execute SQL query
Mysql_select_db ($ mysql_database, $ conn );
$ Res = mysql_query ($ str, $ conn );