【发布时间】:2011-07-01 06:27:27
【问题描述】:
我有一些使用表单编辑的网格。但是在编辑成功后,页面重新加载网格中的数据回到开头。这意味着编辑过程失败。
我很困惑如何将所有变量发布到进程页面中,因为我在这个 php 页面中使用了 switch-case。我在表单中添加了一些隐藏操作:
<form id="editdefdata" class="editable">
<input id="action" name="action" value="changedefdata" type="hidden" />
<button id="defupdate"><span>Update </span></button>
</form>
这个数据将被发布到处理页面:
Problem_date:2011-06-10
Line:FA 14
Shift:N
Model:KD-R321EUD
Serial_number:116V4262
DIC:IQC
Def_class:B
Symptom:CD eject shifting
Cause:Under investigate
Symgrup:Function
Modgrup:KD
oper:edit
def_id:15
这是进程或php页面:
$dbc=mysql_connect(_SRV,_ACCID,_PWD) or die(_ERROR15.": ".mysql_error());
$db=mysql_select_db("qdbase",$dbc) or die(_ERROR17.": ".mysql_error());
switch(postVar('action')) {
case 'oper':
edit(postVar('def_id'),postVar('DIC'),postVar('Def_class'),postVar('Symptom'),postVar('Cause'));
break;
case 'deldefdata':
//postVar blabla....
break;
}
function edit($def_id,$DIC,$Def_class,$Symptom,$Cause){
$defID = mysql_real_escape_string($def_id);
$DIC = mysql_real_escape_string($DIC);
$Defclass = mysql_real_escape_string($Def_class);
$Symp = mysql_real_escape_string($Symptom);
$Cause = mysql_real_escape_string($Cause);
$DIC=strtoupper($DIC);
$Defclass=strtoupper($Defclass);
$sql = "UPDATE oqc_defect SET DIC = '".$DIC."', Def_class = '".$Defclass."', ";
$sql.= "Symptom = '".$Symp."', Cause = '".$Cause."' ";
$sql.= "WHERE def_id = ".$defID;
echo $sql;
$result=mysql_query($sql) or die(_ERROR26.": ".mysql_error());
//echo $result;
mysql_close($dbc);
}
你能告诉我这个案例的正确答案吗?
【问题讨论】:
-
1-您是否看到新的更新影响了您的数据库? 2-您可以创建断点来验证这一点.. 3-您是否使用 fire bug 来检查它...
-
@hameed: 1. 不是,对我的 DB..2 没有影响。当然我做验证..3。在控制台显示 200 OK
-
nunu 你能在你的 process.php 页面中回显 postVar('id') 然后在 firebug 中检查它的响应是什么......它是否返回任何值?
-
@hameed:我必须在哪个部分添加
echo postVar('id')?因为我已经尝试将echo $sql放在里面和下面不显示结果。 -
你可以把 echo 部分放在 switch 之前。