自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL數(shù)據(jù)讀取,ExtJS和PHP Json

數(shù)據(jù)庫(kù) MySQL
此文章主要向大家描述的是ExtJS和PHP Json、MySQL數(shù)據(jù)讀取的實(shí)際應(yīng)用,下面就是對(duì)其正確用法的描述,望你會(huì)有所收獲。

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

ExtJS與PHP Json、MySQL數(shù)據(jù)讀取 1 建立數(shù)據(jù)庫(kù)、注冊(cè)表

 

  1. create database test;  
  2. create table test.login(  
  3. id int primary key,  
  4. name varchar(20) not null,  
  5. password varchar(20) not null  
  6. );  
  7. insert into test.login values  
  8. ('1','hong','1234'),  
  9. ('2','linxiang','1234'),  
  10. ('3','chen','99a9s'),  
  11. ('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ù)

 

  1. jsonreader.php => 
  2. <html> 
  3. <head> 
  4. <title>注冊(cè)</title> 
  5. <link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css" /> 
  6. <script type="text/javascript" src="../ext/adapter/ext/ext-base.js"></script> 
  7. <script type="text/javascript" src="../ext/ext-all.js"></script> 
  8. <script type="text/javascript" src="json.js"></script> 
  9. </head> 
  10. <body> 
  11. <div id='grid'></div> 
  12. </body> 
  13. </html> 
  14. get.php=> 
  15. <?php 
  16. $conn=MySQL_connect("localhost","root","123");  
  17. MySQL_select_db("test");  
  18. $sql="select id,name,password from login";  
  19. $result=MySQL_query($sql,$conn);  
  20. while($row=MySQL_fetch_array($result))  
  21. {  
  22. $arr4[]=$row;  
  23. }  
  24. echo json_encode($arr4);  
  25. ?> 

 

ExtJS與PHP Json、MySQL數(shù)據(jù)讀取 3 extjs文件json.js編寫

  1. json.js=> 
  2. Ext.onReady(function() {  
  3. store=new Ext.data.JsonStore({  
  4. url:'get.php',  
  5. data:[],  
  6. fields:[  
  7. {name:'id'},  
  8. {name:'name'},  
  9. {name:'password'}  
  10. ]  
  11. });  
  12. store.load();  
  13. new Ext.grid.GridPanel({  
  14. store:store,  
  15. mode:'remote',  

title:'簡(jiǎn)單Grid表格示例',

  1. applyTo:'grid',  
  2. width:250,  
  3. height:150,  
  4. frame:true,  
  5. columns:[  
  6. {header:"id",width:50,dataIndex:'id',sortable:true},  
  7. {header:"姓名",width:80,dataIndex:'name',sortable:true},  
  8. {header:"年齡",width:80,dataIndex:'password',sortable:true}  
  9. ]  
  10. })  
  11. }); 

 

 

4 運(yùn)行http://localhost/register/jsonreader.php

 

5 總結(jié)

php獲取MySQL的數(shù)據(jù),轉(zhuǎn)換為數(shù)組,然后運(yùn)用json_encode

 

  1. while($row=mysql_fetch_array($result))  
  2. {  
  3. $arr4[]=$row;  
  4. }  
  5. echo json_encode($arr4); 

以上的相關(guān)內(nèi)容就是對(duì)ExtJS與PHP Json、MySQL數(shù)據(jù)讀取的介紹,望你能有所收獲。

【編輯推薦】

  1. PHP和MySQL存儲(chǔ)過程的實(shí)例演示
  2. 解決MySQL無法遠(yuǎn)程訪問的3方案
  3. 甲骨文對(duì)MySQL數(shù)據(jù)庫(kù)做出十大承諾!
  4. MySQL 常用語句的基本用法的介紹
  5. 安裝MySQL-python的實(shí)際操作步驟
責(zé)任編輯:佚名 來源: cnblogs
相關(guān)推薦

2010-07-28 16:05:47

ExtjsFlex

2010-09-09 16:17:10

PHPXMLXML DOM

2010-05-31 10:19:09

MySQL數(shù)據(jù)庫(kù)時(shí)區(qū)

2011-07-15 14:29:44

PHPXML

2009-12-04 14:09:52

PHP JSON應(yīng)用

2009-12-11 17:57:13

PHP應(yīng)用JSON

2011-05-26 13:54:04

Json

2009-12-10 09:59:49

PHP讀取目錄函數(shù)

2012-06-05 10:52:49

PHP

2009-11-23 10:31:25

PHP使用JSON

2009-12-04 13:54:11

PHP JSON互轉(zhuǎn)函

2024-09-09 18:17:25

PHP編程JSON格式

2010-06-02 15:42:44

MySQL 數(shù)據(jù)亂碼

2021-12-03 09:01:36

PythonJson文件Python基礎(chǔ)

2010-05-19 14:54:33

2010-06-01 16:50:29

MySQL存儲(chǔ)過程

2018-02-10 09:59:51

Java網(wǎng)絡(luò)IO模型

2009-03-09 16:27:17

數(shù)據(jù)遷移PHPOracle

2010-05-13 16:39:25

MySQL5.0

2009-12-07 18:57:17

PHP讀取Cookie
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)