我为我的网页创建了一个搜索功能,以便它可以更新信息。当我搜索记录并更新信息时。然后返回搜索记录再次显示原始信息。我检查了 MySQL 数据库,它确实显示信息发生了变化,但不确定为什么会发生这种情况。以前有人遇到过这个问题吗?
这是我的 index.php 表单
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<meta content="IE=9" http-equiv="X-UA-Compatible">
<link href="css/style01.css" rel="stylesheet"><!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h2 style="text-align: center">Inventory Integrity Edit Request
Form</h2><br>
<br>
<div class="wrapper">
<div class="mainContent">
<form class="form-horizontal" method="get">
<div class="form-group">
<br>
<br>
<label class="col-sm-2 control-label" for="id">Enter
Request ID #</label>
<div class="input-group col-sm-9">
<input class="form-control" id="id" name="=id"
placeholder="Type the id" type="text"> <span class=
"input-group-btn"><button class=
"btn btn-default btnSearch" type="button"><span class=
"input-group-btn"><span class=
"input-group-btn"><span class=
"input-group-btn"><span class=
"input-group-btn"><span class=
"input-group-btn"><span class=
"glyphicon glyphicon-search">Search</span></span></span></span></span></span></button></span>
</div>
</div>
</form>
<div class="col-sm-2"></div>
<div class="col-sm-9">
<!-- This table is where the data is display. -->
<table class="table table-striped table-hover" id=
"resultTable">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>lanId</th>
<th>Department</th>
<th>Manager</th>
<th>Work Requested</th>
<th>PO</th>
<th>IS</th>
<th>Request Comments</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div><!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-1.10.2.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script> <script type="text/javascript">
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);
}
});
}
});
</script>
</body>
</html>
这是我的 search.php 表单
<?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 "<tr>";
echo "<td colspan='4'>There were not records</td>";
echo "</tr>";
}
else {
foreach ($rows as $row) {
echo "<tr>";
$id = $row['id'];
echo "<td><a href='update.php?id=$id'>$id</a></td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['lanId']."</td>";
echo "<td>".$row['department']."</td>";
echo "<td>".$row['mgrname']."</td>";
echo "<td>".$row['work_requested']."</td>";
echo "<td>".$row['purchase_order']."</td>";
echo "<td>".$row['inbound_shipment']."</td>";
echo "<td>".$row['request_comments']."</td>";
echo "</tr>";
}
}
?>
最佳答案
禁用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')
关于php - 更改后不显示新数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27000447/
如何正确创建Rails迁移,以便将表更改为MySQL中的MyISAM?目前是InnoDB。运行原始执行语句会更改表,但它不会更新db/schema.rb,因此当在测试环境中重新创建表时,它会返回到InnoDB并且我的全文搜索失败。我如何着手更改/添加迁移,以便将现有表修改为MyISAM并更新schema.rb,以便我的数据库和相应的测试数据库得到相应更新? 最佳答案 我没有找到执行此操作的好方法。您可以像有人建议的那样更改您的schema.rb,然后运行:rakedb:schema:load,但是,这将覆盖您的数据。我的做法是(假设
我得到了一个包含嵌套链接的表单。编辑时链接字段为空的问题。这是我的表格:Editingkategori{:action=>'update',:id=>@konkurrancer.id})do|f|%>'Trackingurl',:style=>'width:500;'%>'Editkonkurrence'%>|我的konkurrencer模型:has_one:link我的链接模型:classLink我的konkurrancer编辑操作:defedit@konkurrancer=Konkurrancer.find(params[:id])@konkurrancer.link_attrib
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择
我尝试使用不同的ssh_options在同一阶段运行capistranov.3任务。我的production.rb说:set:stage,:productionset:user,'deploy'set:ssh_options,{user:'deploy'}通过此配置,capistrano与用户deploy连接,这对于其余的任务是正确的。但是我需要将它连接到服务器中配置良好的an_other_user以完成一项特定任务。然后我的食谱说:...taskswithoriginaluser...task:my_task_with_an_other_userdoset:user,'an_othe
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
有时我需要处理键/值数据。我不喜欢使用数组,因为它们在大小上没有限制(很容易不小心添加超过2个项目,而且您最终需要稍后验证大小)。此外,0和1的索引变成了魔数(MagicNumber),并且在传达含义方面做得很差(“当我说0时,我的意思是head...”)。散列也不合适,因为可能会不小心添加额外的条目。我写了下面的类来解决这个问题:classPairattr_accessor:head,:taildefinitialize(h,t)@head,@tail=h,tendend它工作得很好并且解决了问题,但我很想知道:Ruby标准库是否已经带有这样一个类? 最佳
假设我有一个FireNinja我的数据库中的对象,使用单表继承存储。后来才知道他真的是WaterNinja.将他更改为不同的子类的最干净的方法是什么?更好的是,我很想创建一个新的WaterNinja对象并替换旧的FireNinja在数据库中,保留ID。编辑我知道如何创建新的WaterNinja来self现有FireNinja的对象,我也知道我可以删除旧的并保存新的。我想做的是改变现有项目的类别。我是通过创建一个新对象并执行一些ActiveRecord魔法来替换行,还是通过对对象本身做一些疯狂的事情,或者甚至通过删除它并使用相同的ID重新插入来做到这一点,这是问题的一部分。