在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1 建立数据库、注册表 create database test;
2 建立jsonreader.php和get.php jsonreader.php调用json.js get.php读取数据库数据 jsonreader.php =>
<html> <head> <title>注册</title> <link rel="stylesheet" type="text/css" href="../ext/resources/css/ext-all.css" /> <script type="text/javascript" src="../ext/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="../ext/ext-all.js"></script> <script type="text/javascript" src="json.js"></script> </head> <body> <div id='grid'></div> </body> </html> get.php=>
<?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); ?> 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 总结
|
2022-11-06
2022-08-17
2022-08-15
2022-08-17
2022-07-18
请发表评论