私はOracleデータベースでjqgridを使用しています。基本的な問題は、データベーステーブルの情報を表示するだけでなく、すべてが正しいように見えることです。私はここに私を助けるかもしれないすべてのコードを残します。
book.php
<?php
//database setting
$dbuser='system';
$dbpassword='manager';
$database='orcl';
$page = 2;
// get the requested page
$limit = 10;
// connect to the database
$db = oci_connect($dbuser, $dbpassword, $database) or die("Connection Error: " . oci_error());
$result = oci_parse($db, 'SELECT COUNT(*) AS count from aaz');
oci_execute($result);
$row = oci_fetch_array ($result);
$count = $row[0];
if( $count > 0 )
{
$total_pages = ceil($count/$limit);
}
else {
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit; // do not put $limit*($page - 1)
$SQL = "SELECT * FROM aaz where rownum <=$limit ORDER BY id";
$result = oci_parse($db, $SQL) or die("Couldn t execute query.".oci_error());
oci_execute($result);
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i=0;
while($row = oci_fetch_array($result,OCI_ASSOC))
{
$responce->rows[$i]['id']=$row[ID];
$responce->rows[$i]['cell']=array($row[ID],$row[FIRSTNAME],$row[LASTNAME],$row[PHONE],$row[EMAIL]);
$i++;
}
echo json_encode($responce);
?>
index.php
<html>
<head>
<title>jQGrid example</title>
<!-- Load CSS--><br />
<link rel="stylesheet" href="css/ui.jqgrid.css" type="text/css" media="all" />
<!-- For this theme, download your own from link above, and place it at css folder -->
<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.23.custom.css" type="text/css" media="all" />
<!-- Load Javascript -->
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-pt.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
</head>
<body>
...
<table id="datagrid"></table>
<div id="navGrid"></div>
<p><script language="javascript">
jQuery("#datagrid").jqGrid({
url:'book.php',
datatype: 'json',
colNames:['ID','Nome', 'Apelido', 'Telefone','Email'],
colModel:[
{name:'ID',index:'ID', width:155,editable:false,editoptions:{readonly:true,size:10}},
{name:'FIRSTNAME',index:'FIRSTNAME', width:180,editable:true,editoptions:{size:10}},
{name:'LASTNAME',index:'LASTNAME', width:190,editable:true,editoptions:{size:25}},
{name:'PHONE',index:'PHONE', width:160, align:"right",editable:true,editoptions:{size:10}},
{name:'EMAIL',index:'EMAIL', width:160, align:"right",editable:true,editoptions:{size:10}}
],
rowNum:10,
rowList:[10,15,20,25,30,35,40],
pager: '#navGrid',
sortname: 'no',
sortorder: "asc",
height: 210,
viewrecords: true,
caption:"Example"
});
jQuery("#datagrid").jqGrid('navGrid','#navGrid',{edit:true,add:true,del:true});
</script>
</body>
</html>
私が得る答えはbook.phpです:
{"page":2、 "total":2、 "records": "12"、 "rows":[{"id": "1"、 "cell":["1"、 "fname1"、 "lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 2 "、" cell ":[" 2 "、" fname1 "、" lname1 "、"(000 )000-0000 "、" name1@gmail.com "]}、{" id ":" 3 "、" cell ":[" 3 "、" fname1 "、" lname1 "、"(000)000-0000 " 、"name1@gmail.com"]}、{"id": "4"、 "cell":["4"、 "fname1"、 "lname1"、 "(000)000-0000"、 "name1 @ gmail .com "]}、{" id ":" 5 "、" cell ":[" 5 "、" fname1 "、" lname1 "、"(000)000-0000 "、"name1@gmail.com "]}、{" id ":" 6 "、" cell ":[" 6 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 7 "、" cell ":[" 7 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{ "id": "8"、 "cell":["8"、 "fname1"、 "lname1"、 "(000)000-0000"、 "name1@gmail.com"]}、{"id": " 9 "、" cell ":[" 9 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 10 "、" cell ":[" 10 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}]}cell ":[" 6 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 7 "、" cell ":[" 7 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 8 "、" cell ":[" 8 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 9 "、" cell ":[" 9 "、" fname1 "、" lname1 " 、"(000)000-0000"、 "name1@gmail.com"]}、{"id": "10"、 "cell":["10"、 "fname1"、 "lname1"、 "(000) 000-0000 "、" name1@gmail.com "]}]}cell ":[" 6 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 7 "、" cell ":[" 7 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 8 "、" cell ":[" 8 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 9 "、" cell ":[" 9 "、" fname1 "、" lname1 " 、"(000)000-0000"、 "name1@gmail.com"]}、{"id": "10"、 "cell":["10"、 "fname1"、 "lname1"、 "(000) 000-0000 "、" name1@gmail.com "]}]}]}、{"id": "7"、 "cell":["7"、 "fname1"、 "lname1"、 "(000)000-0000"、 "name1@gmail.com"]}、{" id ":" 8 "、" cell ":[" 8 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 9 "、" cell ":[" 9 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 10 "、" cell " :["10"、 "fname1"、 "lname1"、 "(000)000-0000"、 "name1@gmail.com"]}]}]}、{"id": "7"、 "cell":["7"、 "fname1"、 "lname1"、 "(000)000-0000"、 "name1@gmail.com"]}、{" id ":" 8 "、" cell ":[" 8 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 9 "、" cell ":[" 9 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 10 "、" cell " :["10"、 "fname1"、 "lname1"、 "(000)000-0000"、 "name1@gmail.com"]}]}fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 9 "、" cell ":[" 9 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 10 "、" cell ":[" 10 "、" fname1 "、" lname1 "、"(000 )000-0000 "、" name1@gmail.com "]}]}fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 9 "、" cell ":[" 9 "、" fname1 "、" lname1 "、"(000)000-0000 "、" name1@gmail.com "]}、{" id ":" 10 "、" cell ":[" 10 "、" fname1 "、" lname1 "、"(000 )000-0000 "、" name1@gmail.com "]}]}
誰かが私を助けることができますか?