关于jqgrid的问题
一。本地测试可以显示数据库数据,上传到服务器上就显示不了,sql都在phpmyadmin测试过,可以用的,请问怎么查是什么原因。
二。编码问题,页面本来编码为GB的,我把sale_list.html和do.php用记事本转成utf-8后,本地测试jqgrid就显示不了数据。
do.php源码
<?phpinclude_once ("conn.php");$action = $_GET['action'];switch ($action) { case 'list' : //列表 $page = $_GET['page']; $limit = $_GET['rows']; $sidx = $_GET['sidx']; $sord = $_GET['sord'];// $page = 1;// $limit = 12;// $sidx = 'id';// $sord = 'asc'; if (!$sidx) $sidx = 1; $where = ''; $product_name = uniDecode($_GET['product_name'],'utf-8'); if(!empty($product_name)) $where .= " and `product-name` like '%".$product_name."%'"; $order_id = uniDecode($_GET['order_id'],'utf-8'); if(!empty($order_id)) // $where .= " and order_id='$order_id'"; $where .= " and `order_id` like '%".$order_id."%'"; //$result = mysql_query("SELECT COUNT(*) AS count FROM products where deleted=0".$where); $result = mysql_query("SELECT COUNT(*) AS count FROM `sale_orders` WHERE `number`>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 <mark>@本文来源gaodaimacom搞#代%码@网-</mark><strong>搞代gaodaima码</strong>($start0".$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