首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Easyui数据搜索不起作用

Easyui数据搜索不起作用
EN

Stack Overflow用户
提问于 2017-09-26 10:42:26
回答 2查看 159关注 0票数 0

EasyUi数据搜索在PHP7.6版中不起作用,但在PHP5.6版中运行良好。

如何修复此错误?有人能帮我解决这个问题吗?我是php新手。

请在下面找到我的密码。

代码语言:javascript
复制
<?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);
?>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-09-28 07:12:41

我修改了我的php代码,如下所示。现在一切都很好。

代码语言:javascript
复制
<?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
EN

Stack Overflow用户

发布于 2017-09-26 10:59:42

请使用mysqli或pdo作为数据库扩展,没有mysql,所以不要使用"mysql_query“,而要使用"mysqli_query”等等。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46424257

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档