新聞中心
以下的文章主要講述的是ExtJS和PHP Json、MySQL數(shù)據(jù)讀取的實(shí)際應(yīng)用,種種包括建立數(shù)據(jù)庫(kù)、注冊(cè)表,建立jsonreader.php和get.php與extjs文件json.js編寫(xiě),以下就是文章的主要內(nèi)容描述。

成都創(chuàng)新互聯(lián)公司專(zhuān)注于企業(yè)營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、網(wǎng)站重做改版、牟平網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、成都h5網(wǎng)站建設(shè)、商城建設(shè)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)營(yíng)銷(xiāo)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性?xún)r(jià)比高,為牟平等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。
ExtJS與PHP Json、MySQL數(shù)據(jù)讀取 1 建立數(shù)據(jù)庫(kù)、注冊(cè)表
- create database test;
- create table test.login(
- id int primary key,
- name varchar(20) not null,
- password varchar(20) not null
- );
- insert into test.login values
- ('1','hong','1234'),
- ('2','linxiang','1234'),
- ('3','chen','99a9s'),
- ('4','luxi','aabe2');
ExtJS與PHP Json、MySQL數(shù)據(jù)讀取 2 建立jsonreader.php和get.php
jsonreader.php調(diào)用json.js
get.php讀取數(shù)據(jù)庫(kù)數(shù)據(jù)
- jsonreader.php =>
注冊(cè) - get.php=>
- $conn=MySQL_connect("localhost","root","123");
- MySQL_select_db("test");
- $sql="select id,name,password from login";
- $result=MySQL_query($sql,$conn);
- while($row=MySQL_fetch_array($result))
- {
- $arr4[]=$row;
- }
- echo json_encode($arr4);
- ?>
ExtJS與PHP Json、MySQL數(shù)據(jù)讀取 3 extjs文件json.js編寫(xiě)
- json.js=>
- Ext.onReady(function() {
- store=new Ext.data.JsonStore({
- url:'get.php',
- data:[],
- fields:[
- {name:'id'},
- {name:'name'},
- {name:'password'}
- ]
- });
- store.load();
- new Ext.grid.GridPanel({
- store:store,
- mode:'remote',
title:'簡(jiǎn)單Grid表格示例',
- applyTo:'grid',
- width:250,
- height:150,
- frame:true,
- columns:[
- {header:"id",width:50,dataIndex:'id',sortable:true},
- {header:"姓名",width:80,dataIndex:'name',sortable:true},
- {header:"年齡",width:80,dataIndex:'password',sortable:true}
- ]
- })
- });
4 運(yùn)行http://localhost/register/jsonreader.php
5 總結(jié)
php獲取MySQL的數(shù)據(jù),轉(zhuǎn)換為數(shù)組,然后運(yùn)用json_encode
- while($row= mysql _fetch_array($result))
- {
- $arr4[]=$row;
- }
- echo json_encode($arr4);
以上的相關(guān)內(nèi)容就是對(duì)ExtJS與PHP Json、MySQL數(shù)據(jù)讀取的介紹,望你能有所收獲。
當(dāng)前文章:MySQL數(shù)據(jù)讀取,ExtJS和PHPJson
分享鏈接:http://fisionsoft.com.cn/article/ccispio.html


咨詢(xún)
建站咨詢(xún)
