当前位置:Gxlcms > PHP教程 > 关于jqgrid的问题

关于jqgrid的问题

时间:2021-07-01 10:21:17 帮助过:10人阅读

关于jqgrid的问题
一。本地测试可以显示数据库数据,上传到服务器上就显示不了,sql都在phpmyadmin测试过,可以用的,请问怎么查是什么原因。

二。编码问题,页面本来编码为GB的,我把sale_list.html和do.php用记事本转成utf-8后,本地测试jqgrid就显示不了数据。

do.php源码
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 `sale_orders` WHERE `number`>0".$where." ORDER BY $sidx $sord LIMIT $start , $limit";		$result = mysql_query($SQL);		$responce->page = $page;		$responce->total = $total_pages;		$responce->records = $count;		$i = 0;		while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {			$responce->rows[$i]['order_id'] = $row['order_id'];			$opt = "修改";			$responce->rows[$i]['cell'] = array (				$row['order_id'],				$row['buyer-name'],				$row['jj_sku'],				$row['sku'],				$row['product-name'],				$row['quantity-purchased'],				$opt			);			$i++;		}		//print_r($responce);		echo json_encode($responce);		break;	case 'add' : //新增		$pro_title = htmlspecialchars(stripslashes(trim($_POST['pro_title'])));		$pro_sn = htmlspecialchars(stripslashes(trim($_POST['pro_sn'])));		$size = htmlspecialchars(stripslashes(trim($_POST['size'])));		$os = htmlspecialchars(stripslashes(trim($_POST['os'])));		$charge = htmlspecialchars(stripslashes(trim($_POST['charge'])));		$price = htmlspecialchars(stripslashes(trim($_POST['price'])));		if (mb_strlen($pro_title) < 1)			die("产品名称不能为空");		$addtime = date('Y-m-d H:i:s');		$query = mysql_query("insert into products(sn,title,size,os,charge,price,addtime)values('$pro_sn','$pro_title','$size','$os','$charge','$price','$addtime')");		if (mysql_affected_rows($conn) != 1) {			die("操作失败");		} else {			echo '1';		}		break;	case 'del' : //删除		$ids = $_POST['ids'];		delAllSelect($ids, $conn);		break;	case '' :		echo 'Bad request.';		break;}//批量删除操作function delAllSelect($ids, $conn) {	if (empty ($ids))		die("0");	//mysql_query("update products set deleted=1 where id in($ids)");		mysql_query("delete FROM `sale_orders` WHERE order_id='$ids'");	if (mysql_affected_rows($conn)) {		echo $ids;	} else {		die("0");	}}//处理接收jqGrid提交查询的中文字符串function uniDecode($str, $charcode) {	$text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", toUtf8, $str);	return mb_convert_encoding($text, $charcode, 'utf-8');}function toUtf8($ar) {	foreach ($ar as $val) {		$val = intval(substr($val, 2), 16);		if ($val < 0x7F) { // 0000-007F			$c .= chr($val);		}		elseif ($val < 0x800) { // 0080-0800			$c .= chr(0xC0 | ($val / 64));			$c .= chr(0x80 | ($val % 64));		} else { // 0800-FFFF			$c .= chr(0xE0 | (($val / 64) / 64));			$c .= chr(0x80 | (($val / 64) % 64));			$c .= chr(0x80 | ($val % 64));		}	}	return $c;}echo $page;echo $limit;echo $sidx;echo $sord;?>


回复讨论(解决方案)

楼主的数据库编码是什么呀,必须和页面统一哦。

qGrid 是一个用来显示网格数据的jQuery插件
传递给他的数据应该是 json,你就简单的
echo $page;
echo $limit;
echo $sidx;
echo $sord;
算什么?

echo $page;
echo $limit;
echo $sidx;
echo $sord;
因为后面两个变更我不知道什么意思,所以想输出一下看看
sale_list.html

jqGrid:强大的表格插件的应用-Helloweba演示平台

销售订单列表

人气教程排行