[英]Redirect after save or edit data?
If I have 2-30 record it nothing wrong in my screen just scroll down.如果我有 2-30 条记录,它在我的屏幕上没有任何问题,只需向下滚动即可。
But when i have 30++ record it take more time Where the record saved or the record just edited.但是当我有 30++ 记录时,需要更多时间来保存记录或刚刚编辑的记录。
My question is, can I redirect to the record just saved or edited?我的问题是,我可以重定向到刚刚保存或编辑的记录吗? It's easy using link such as:使用链接很容易,例如:
<a href="#yourdataeditedhere">Go to your edited record</a>
And than my screen sroll to the #yourdataeditedhere<br>
No need to sroll like link menu.
<div id="yourdataeditedhere">Record Just Edited</div>
My problem is:我的问题是:
index.php索引.php
<html>
<form name="frmMain" method="post" action="edit.php">
<input type="hidden" name="hdnCmd" value="">
<input type="hidden" name="produkid" value="<? print $row['produkid']; ?>">
<input type="submit" name="simpan" value="Simpan">
<input type="text" name="produkname">
<input type="button" value="Update" OnClick="frmMain.hdnCmd.value='Updateprodukname';frmMain.submit();">
</form>
simpan.php simpan.php
<? if($_POST["hdnCmd"] == "Updateprodukname")
{
if (empty($produkname))
{
header("location:index.php?status=Error&Action=Editprodukname&produkid=$produkid#produkid=$produkid");
}
else
{
$myqry="UPDATE produk SET produkname='$produkname' WHERE produkid='$produkid' LIMIT 1";
mysql_query($myqry) or die(mysql_error());
header("location:index.php?status=success&produkid=$produkid#produkid=$produkid");
exit;
}
}
?>
I try add &produkid=$produkid
and #produkid=$produkid
at header simpan.php我尝试在标题 simpan.php 添加&produkid=$produkid
和#produkid=$produkid
produkid
But when record, it fails or edited when page refresh my screen on top.但是当记录时,当页面在顶部刷新我的屏幕时它会失败或被编辑。
What I need is, like some reply forum.我需要的是,像一些回复论坛。 After I reply the other people reply message, after refresh my screen go to page of his/her reply message and my screen scrolled to his/her reply message not on top or bottom.在我回复其他人的回复消息后,刷新我的屏幕后转到他/她的回复消息页面,我的屏幕滚动到他/她的回复消息,而不是顶部或底部。
That happens because you insert $variable into a string.发生这种情况是因为您将 $variable 插入到字符串中。
Try:尝试:
header('Location: index.php?status=success&produkid=' . $produkid . '#produkid=' . $produkid);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.