PHP讀取資料庫顯示有關問題

來源:互聯網
上載者:User
PHP讀取資料庫顯示問題
請教各位,我的資料庫資料如下:-
-- 表的結構 `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 ;

--
-- 轉存表中的資料 `3g_district`
--

INSERT INTO `3g_district` (`d_id`, `d_name`, `d_level`, `d_pid`, `d_list`) VALUES
(1, '北京市', 1, 0, 0),
(2, '天津市', 1, 0, 0),
(3, '河北省', 1, 0, 0),
(4, '山西省', 1, 0, 0),
(5, '內蒙古自治區', 1, 0, 0),
(6, '遼寧省', 1, 0, 0),
(7, '吉林省', 1, 0, 0),
(8, '黑龍江省', 1, 0, 0),
(9, '上海市', 1, 0, 0),
(10, '江蘇省', 1, 0, 0),
(11, '浙江省', 1, 0, 0),
(12, '安徽省', 1, 0, 0),
(13, '福建省', 1, 0, 0),
(14, '江西省', 1, 0, 0),
(15, '山東省', 1, 0, 0),
(16, '河南省', 1, 0, 0),
(17, '湖北省', 1, 0, 0),
(18, '湖南省', 1, 0, 0),
(19, '廣東省', 1, 0, 0),
(20, '廣西壯族自治區', 1, 0, 0),
(21, '海南省', 1, 0, 0),
(22, '重慶市', 1, 0, 0),
(23, '四川省', 1, 0, 0),


我的conn.php檔案如下:


$mysql_server_name="localhost"; //資料庫伺服器名稱
$mysql_username="root"; //串連資料庫使用者名稱
$mysql_password=""; //串連資料庫密碼
$mysql_database="teafea"; //資料庫的名字

//串連到資料庫
$conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

//使用utf8編碼
mysql_query("set names 'utf8'");

//從表中提取資訊的sql語句
$str="select d_id,d_name from 3g_district";

//執行sql查詢
mysql_select_db($mysql_database,$conn);
$res=mysql_query($str,$conn);
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.