php防止改数据,php-进行更改后不显示新数据

我为网页创建了搜索功能,以便它可以更新信息.当我搜索记录并更新信息时.然后返回以再次搜索记录,显示原始信息.我检查了MySQL数据库,它确实表明信息已更改,不确定为什么会发生这种情况.有人遇到过这个问题吗?

这是我的index.php表格

Inventory Integrity Edit Request

Form

Enter

Request ID #

placeholder="Type the id" type="text">

"input-group-btn">

"btn btn-default btnSearch" type="button">

"input-group-btn">

"input-group-btn">

"input-group-btn">

"input-group-btn">

"input-group-btn">

"glyphicon glyphicon-search">Search

"resultTable">

IdNamelanIdDepartmentManagerWork RequestedPOISRequest Comments

jQuery(document).ready(function($) {

$('.btnSearch').click(function(){

makeAjaxRequest();

});

$('form').submit(function(e){

e.preventDefault();

makeAjaxRequest();

return false;

});

function makeAjaxRequest() {

$.ajax({

url: 'php/search.php',

type: 'get',

data: {id: $('input#id').val()},

success: function(response) {

$('table#resultTable tbody').html(response);

}

});

}

});

这是我的search.php表格

require_once 'db_connect.php';

$conn = dbConnect();

$OK = true; // We use this to verify the status of the update.

if (isset($_GET['id'])) {

// Create the query

$data = "%".$_GET['id']."%";

$sql = 'SELECT * FROM requests WHERE id like ?';

$stmt = $conn->prepare($sql);

$results = $stmt->execute(array($data));

$rows = $stmt->fetchAll();

$error = $stmt->errorInfo();

//echo $error[2];

}

// If there are no records.

if(empty($rows)) {

echo "

";

echo "

There were not records";

echo "

";

}

else {

foreach ($rows as $row) {

echo "

";

$id = $row['id'];

echo "

$id";

echo "

".$row['name']."";

echo "

".$row['lanId']."";

echo "

".$row['department']."";

echo "

".$row['mgrname']."";

echo "

".$row['work_requested']."";

echo "

".$row['purchase_order']."";

echo "

".$row['inbound_shipment']."";

echo "

".$row['request_comments']."";

echo "

";

}

}

?>

解决方法:

禁用ajax缓存:

$.ajax({

url: 'php/search.php',

cache: false,

type: 'get',

data: {

id: $('input#id').val()

},

success: function (response) {

$('table#resultTable tbody').html(response);

}

});

编辑:从jQuery.ajax()的jQuery API文档中:

cache (default: true, false for dataType ‘script’ and ‘jsonp’)

标签:mysql,php,pdo

来源: https://codeday.me/bug/20191121/2048697.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值