Heim >Backend-Entwicklung >PHP-Tutorial >jqgrid显示不了数据解决方案

jqgrid显示不了数据解决方案

WBOY
WBOYOriginal
2016-06-13 12:06:24948Durchsuche

jqgrid显示不了数据
jqgrid显示不数据,请各位大大帮忙看看

<br /><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /><title>无标题文档</title><br /><link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.2.custom.css" /><br /><link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" /><br /><br /><script src="js/jquery-1.9.0.min.js" type="text/javascript"></script><br /><script src="js/i18n/grid.locale-cn.js" type="text/javascript"></script><br /><script src="js/jquery.jqGrid.min.js" type="text/javascript"></script><br /><br /><script type="text/javascript"><br />$(function(){ <br />jQuery("#list").jqGrid({<br />   	url:'dd.php',<br />	datatype: "json",<br />	height: 255,<br />	width: 600,<br />   	colNames:['编号','名称','主屏尺寸','操作系统','电池容量', '价格(¥)','操作'], //数据列名称(数组)<br />   	colModel:[ //数据列各参数信息设置<br />   		{name:'sn',index:'sn', editable:true, width:80,align:'center',title:false,editable: true,edittype:"text"},<br />   		{name:'title',index:'title', width:180,title:false, editable: true,sorttype:"text"},<br />   		{name:'size',index:'size', width:120, editable: true,sorttype:"text"},<br />		{name:'os',index:'os', width:120,editable:true,sorttype:"text"},<br />   		{name:'charge',index:'charge', width:100,align:'center',editable:true,sorttype:"text"},<br />		{name:'price',index:'price', width:80,align:'center',editable:true,sorttype:"text"},<br />   		{name:'opt',index:'opt', width:80, sortable:false, align:'center',editable:true,sorttype:"text"}		<br />   	],<br />   	rowNum:50,<br />	rowTotal: 2000,<br />	rowList : [20,30,50],<br />	loadonce:true,<br />   	mtype: "GET",<br />	rownumbers: true,<br />	rownumWidth: 40,<br />	gridview: true,<br />   	pager: '#pager',<br />   	sortname: 'id',<br />    viewrecords: true,<br />    sortorder: "asc",<br />	caption: "Toolbar Searching"	<br />});<br /><br />jQuery("#list").jqGrid('navGrid','#pager',{del:false,add:false,edit:false,search:false});<br />jQuery("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});<br />  <br />}); <br /></script><br /><br /></head><br /><body><br /><br /><table id="list"></table><br /><div id="page" ></div><br /><br /></body><br /></html><br />


<br><?PHP <br /><br>include_once ("connect.php");<br><br>	$page = $_GET['page'];<br>		$limit = $_GET['rows'];<br>		$sidx = $_GET['sidx'];<br>		$sord = $_GET['sord'];<br>		if (!$sidx)<br>			$sidx = 1;<br>        $where = '';<br>        $title = uniDecode($_GET['title'],'utf-8');<br>        if(!empty($title))<br>            $where .= " and title like '%".$title."%'";<br>        $sn = uniDecode($_GET['sn'],'utf-8');<br>        if(!empty($sn))<br>            $where .= " and sn='$sn'";<br><br>		$result = mysql_query("SELECT COUNT(*) AS count FROM products where deleted=0".$where);<br>		$row = mysql_fetch_array($result, MYSQL_ASSOC);<br>		$count = $row['count'];<br>		//echo $count;<br>		if ($count > 0) {<br>			$total_pages = ceil($count / $limit);<br>		} else {<br>			$total_pages = 0;<br>		}<br>		if ($page > $total_pages)<br>			$page = $total_pages;<br>		$start = $limit * $page - $limit;<br>		if ($start		$SQL = "SELECT * FROM products WHERE deleted=0".$where." ORDER BY $sidx $sord LIMIT $start , $limit";<br>		$result = mysql_query($SQL) or die("Couldn t execute query." . mysql_error());<br><br>		$responce->page = $page;<br>		$responce->total = $total_pages;<br>		$responce->records = $count;<br>		$i = 0;<br>		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {<br>			$responce->rows[$i]['id'] = $row[id];<br>			$opt = "<a>修改</a>";<br>			$responce->rows[$i]['cell'] = array (<br>				$row['sn'],<br>				$row['title'],<br>				$row['size'],<br>				$row['os'],<br>				$row['charge'],<br>				$row['price'],<br>				$opt<br>			);<br>			$i++;<br>		}<br>		//print_r($responce);<br>		echo json_encode($responce);<br>		<br>	<br>		<br>		<br>	function uniDecode($str, $charcode) {<br>	$text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", toUtf8, $str);<div class="clear">
                 
              
              
        
            </div>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn