首页新闻找找看学习计划

ext从数据库取结果显示不出来

0
[已解决问题] 解决于 2014-03-31 10:59
 1 <script type="text/javascript">
 2 $(document).ready(function(){
 3     alertByText("a",urlText2());
 4 });
 5 function urlText2(){
 6     var big = "<?=$_REQUEST["bigname"]?>";
 7     var second = "<?=$_REQUEST["secondname"]?>";
 8     var third = "<?=$_REQUEST["thirdname"]?>";
 9     var four = "<?=$_REQUEST["fourname"]?>";
10     var five = "<?=$_REQUEST["fivename"]?>";
11     return "<?=base_url() ?>index.php/selectInfo/selectResults?bigname="+
12     big+"&secondname="+second+"&thirdname="+third+"&fourname="+four+"&fivename="+five;
13 }
14    Ext.onReady(function(){
15        pagesize=20;//定义分页大小
16 
17 store=new Ext.data.JsonStore({
18     url:urlText2(),
19 //data:[],
20 fields:["expression_system_plant","code_number","protein_name","country","time"]
21 });
22 
23  var pagetool = pagingTool(store);
24 
25 store.load();
26 
27 var colM=new Ext.grid.ColumnModel([
28 {header:"代码号",dataIndex:"code_number",sortable:true,renderer:showUrl},
29 {header:"项目名称",dataIndex:"protein_name",sortable:true},
30 {header:"表达体系",dataIndex:"expression_system_plant",sortable:true},
31 {header:"国家",dataIndex:"country",sortable:true},
32 {header:"时间",dataIndex:"time",sortable:true}]);
33 
34 var grid = new Ext.grid.GridPanel({
35 renderTo:"un",
36 title:"查询结果",
37 height:400,
38 width:600,
39 cm:colM,
40 store:store,
41 frame:true,  
42 stripeRows:true,
43 bbar:pagetool,
44 autoExpandColumn:2
45 });
46 }
47 );
48 
49 
50 // 返回分页工具条
51 function pagingTool(store)
52 {
53     var pagetool = new Ext.PagingToolbar (  {
54                 pageSize:pagesize,
55                 store:store,
56                 displayInfo:true,
57                 displayMsg : '显示第{0}条到{1}条记录 ,一共{2}条',
58                 emptyMsg: "没有记录"
59     });
60     return pagetool;
61 }
62 function showUrl(value){
63       return "<a href="+"<?=base_url()?>index.php/selectInfo/linkResult?code_number="+value+">"+value+"</a>";
64 65 </script>
66 <div class="section" id="content">
67 
68         <div id="un"></div>
69       </div>
70       <div id="clear"></div>

????????????????????????????????????????????????????????????????????????????????
 1 public function selectResultByThird() {
 2         if ((!empty ($_REQUEST["bigname"])) && (!empty ($_REQUEST["secondname"])) && (!empty ($_REQUEST["thirdname"])) && (!empty ($_REQUEST["fourname"])) && (!empty ($_REQUEST["fivename"]))) {
 3 
 4             $bigid = $_REQUEST["bigname"];
 5             $bigid = iconv("gb2312","utf-8",$bigid);
 6             $secondid = $_REQUEST["secondname"]; //从页面取得提交的二类
 7             $secondid = iconv("gb2312","utf-8",$secondid);
 8             $thirdname = $_REQUEST["thirdname"]; //从页面取得提交的三类
 9             $thirdname = iconv("gb2312","utf-8",$thirdname);
10             $fourname = $_REQUEST["fourname"]; //从页面取得提交的四类
11             $fourname = iconv("gb2312","utf-8",$fourname);
12             $fivename = $_REQUEST["fivename"]; //从页面取得提交的五类
13             $fivename = iconv("gb2312","utf-8",$fivename);
14 //            $start = $_REQUEST["start"];
15 //            $limit = $_REQUEST["limit"];
16             $start = ($_REQUEST["start"] = '') ? $_REQUEST["start"] : 0; //处理分页用到的变量
17             $limit = ($_REQUEST["limit"] = '') ? $_REQUEST["limit"] : 20;
18             $page = "$start" . "," . "$limit";
19             $sql = "SELECT * FROM `protein` WHERE expression_system_plant LIKE " . "'$secondid'" .
20             "and protein_name LIKE " . "'$bigid'" . "and country LIKE " . "'$thirdname'" .
21             "and commercialization_process like " . "'$fourname'" . "and time like " . "'$fivename'"." LIMIT ".$page;
22 //            echo $sql;
23             $count = mysql_query($sql);
24             $arr = array ();
25             while ($obj = mysql_fetch_object($count)) {
26                 $arr[] = $obj;
27             }
28             echo json_encode($arr);
29 
30         }
31     }
Tim&Blog的主页 Tim&Blog | 初学一级 | 园豆:200
提问于:2013-08-01 15:22
< >
分享
最佳答案
0

前台js 应该都没有加载数据,你是动态加载数据的,但是你的store确是静态方式,改成下面的方式试试:

store = new Ext.data.Store({
        autoLoad : true,
        proxy : new Ext.data.HttpProxy({
            url : urlText2()
        }),
        reader : new Ext.data.JsonReader({
            fields : [
                "expression_system_plant", 
                "code_number",
                "protein_name", 
                "country", 
                "time"
            ]
        })
    });
奖励园豆:5
宁静*勤奋 | 菜鸟二级 |园豆:226 | 2013-08-01 15:34

谢谢 已经成功

Tim&Blog | 园豆:200 (初学一级) | 2013-08-01 15:50

太客气

宁静*勤奋 | 园豆:226 (菜鸟二级) | 2013-08-02 15:59
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册