2017-09-26 56 views
0

EasyUi datagrid搜索不能在PHP 7.6版本中工作,但它在PHP 5.6版本中工作正常。Easyui datagrid搜索不起作用

我該如何解決這個錯誤?任何人都可以幫助我解決這個問題?我是PHP新手。

請在下面找到我的代碼。

<?php 
include 'conn.php'; 

$page = isset($_POST['page']) ? intval($_POST['page']) : 1; 
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; 
$itemid = isset($_POST['id']) ? mysql_real_escape_string($_POST['id']) : ''; 
$productid = isset($_POST['proc_id']) ? mysql_real_escape_string($_POST['proc_id']) : ''; 

$offset = ($page-1)*$rows; 

$result = array(); 

$where = "id like '$itemid%' and proc_id like '$productid%'"; 
$rs = mysql_query("select count(*) from details_v9 where " . $where); 
$row = mysql_fetch_row($rs); 
$result["total"] = $row[0]; 

$rs = mysql_query("select * from details_v9 where " . $where . " limit $offset,$rows"); 

$items = array(); 
while($row = mysql_fetch_object($rs)){ 
    array_push($items, $row); 
} 
$result["rows"] = $items; 

echo json_encode($result); 
?> 

回答

0

我修改我的PHP代碼如下圖所示。現在工作正常。

<?php 
include 'conn.php'; 

$page = isset($_POST['page']) ? intval($_POST['page']) : 1; 
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10; 
$itemid = isset($_POST['id']) ? $_POST['id'] : false; 
$productid = isset($_POST['proc_id']) ? $_POST['proc_id'] : false; 

$offset = ($page-1)*$rows; 

$result = array(); 

$where = "id like '$itemid%' and proc_id like '$productid%'"; 
$rs = mysql_query("select count(*) from details_v9 where " . $where); 
$row = mysql_fetch_row($rs); 
$result["total"] = $row[0]; 

$rs = mysql_query("select * from details_v9 where " . $where . " limit $offset,$rows"); 

$items = array(); 
while($row = mysql_fetch_object($rs)){ 
    array_push($items, $row); 
} 
$result["rows"] = $items; 

echo json_encode($result); 
?> 
0

請使用庫MySQLi或PDO作爲數據庫擴展沒有mysql 所以不是「的mysql_query」使用「mysqli_query」等..

+0

我只使用mysqli_query ..但它不工作 – Thangavel