jqgrid显示不数据,请各位大大帮忙看看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.2.custom.css?3.8.99" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css?3.8.99" />
<script src="js/jquery-1.9.0.min.js?3.8.99" type="text/javascript"></script>
<script src="js/i18n/grid.locale-cn.js?3.8.99" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js?3.8.99" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
jQuery("#list").jqGrid({
url:'dd.php',
datatype: "json",
height: 255,
width: 600,
colNames:['编号','名称','主屏尺寸','操作系统','电池容量', '价格(¥)','操作'], //数据列名称(数组)
colModel:[ //数据列各参数信息设置
{name:'sn',index:'sn', editable:true, width:80,align:'center',title:false,editable: true,edittype:"text"},
{name:'title',index:'title', width:180,title:false, editable: true,sorttype:"text"},
{name:'size',index:'size', width:120, editable: true,sorttype:"text"},
{name:'os',index:'os', width:120,editable:true,sorttype:"text"},
{name:'charge',index:'charge', width:100,align:'center',editable:true,sorttype:"text"},
{name:'price',index:'price', width:80,align:'center',editable:true,sorttype:"text"},
{name:'opt',index:'opt', width:80, sortable:false, align:'center',editable:true,sorttype:"text"}
],
rowNum:50,
rowTotal: 2000,
rowList : [20,30,50],
loadonce:true,
mtype: "GET",
rownumbers: true,
rownumWidth: 40,
gridview: true,
pager: '#pager',
sortname: 'id',
viewrecords: true,
sortorder: "asc",
caption: "Toolbar Searching"
});
jQuery("#list").jqGrid('navGrid','#pager',{del:false,add:false,edit:false,search:false});
jQuery("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
});
</script>
</head>
<body>
<table id="list"></table>
<p id="page" ></p>
</body>
</html>
<?PHP
include_once ("connect.php");
$page = $_GET['page'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
if (!$sidx)
$sidx = 1;
$where = '';
$title = uniDecode($_GET['title'],'utf-8');
if(!empty($title))
$where .= " and title like '%".$title."%'";
$sn = uniDecode($_GET['sn'],'utf-8');
if(!empty($sn))
$where .= " and sn='$sn'";
$result = mysql_query("SELECT COUNT(*) AS count FROM products where deleted=0".$where);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$count = $row['count'];
//echo $count;
if ($count > 0) {
$total_pages = ceil($count / $limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages)
$page = $total_pages;
$start = $limit * $page - $limit;
if ($start<0) $start = 0;
$SQL = "SELECT * FROM products WHERE deleted=0".$where." ORDER BY $sidx $sord LIMIT $start , $limit";
$result = mysql_query($SQL) or die("Couldn t execute query." . mysql_error());
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$responce->rows[$i]['id'] = $row[id];
$opt = "<a href='#'>修改</a>";
$responce->rows[$i]['cell'] = array (
$row['sn'],
$row['title'],
$row['size'],
$row['os'],
$row['charge'],
$row['price'],
$opt
);
$i++;
}
//print_r($responce);
echo json_encode($responce);
function uniDecode($str, $charcode) {
$text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", toUtf8, $str);
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群