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

成都創(chuàng)新互聯(lián)公司專注于企業(yè)營銷型網(wǎng)站建設、網(wǎng)站重做改版、牟平網(wǎng)站定制設計、自適應品牌網(wǎng)站建設、成都h5網(wǎng)站建設、商城建設、集團公司官網(wǎng)建設、外貿(mào)營銷網(wǎng)站建設、高端網(wǎng)站制作、響應式網(wǎng)頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為牟平等各大城市提供網(wǎng)站開發(fā)制作服務。
ExtJS與PHP Json、MySQL數(shù)據(jù)讀取 1 建立數(shù)據(jù)庫、注冊表
- 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ù)庫數(shù)據(jù)
- jsonreader.php =>
注冊 - 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編寫
- 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:'簡單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 運行http://localhost/register/jsonreader.php
5 總結(jié)
php獲取MySQL的數(shù)據(jù),轉(zhuǎn)換為數(shù)組,然后運用json_encode
- while($row= mysql _fetch_array($result))
- {
- $arr4[]=$row;
- }
- echo json_encode($arr4);
以上的相關(guān)內(nèi)容就是對ExtJS與PHP Json、MySQL數(shù)據(jù)讀取的介紹,望你能有所收獲。
網(wǎng)站欄目:MySQL數(shù)據(jù)讀取,ExtJS和PHPJson
URL標題:http://m.5511xx.com/article/ccispio.html


咨詢
建站咨詢
