EasyUi datagrid搜索在php 7.6版本中不起作用,但它在php 5.6版本中运行良好。
如何修复此错误?有人可以帮我解决这个问题吗?我是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 :(得分:0)
请使用mysqli或pdo作为数据库扩展名没有mysql 所以代替“mysql_query”使用“mysqli_query”等等......
答案 1 :(得分: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);
?>