admin管理员组文章数量:1426648
i need a javascript to help me refresh my page after i update the data. i have coded out t he update function all i need to refresh the page after the data is updated how do i do that.
This is what i have done so far
<?php
mysql_connect("localhost","fbappsadmin","dbP@ssw0rd") or die(mysql_error()) ;
mysql_select_db("jetstardatabase") or die(mysql_error()) ;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$options = array(
'1' => 1,
'2' => 2,
);
if (isset($_POST['list'])) {
$value = (int)$_POST['list'];
} else {
$value = 0; // default value;
}
$cmeter = $cmeter - $value;
mysql_query("INSERT orders SET quantity='$value',fbId='$fbme',fbName='$fbName', email ='$fbEmail', dealName='$dealName'" );
mysql_query("UPDATE stardeal SET cmeter='$cmeter'WHERE dealId='$dealId'");
}
?>
i need a javascript to help me refresh my page after i update the data. i have coded out t he update function all i need to refresh the page after the data is updated how do i do that.
This is what i have done so far
<?php
mysql_connect("localhost","fbappsadmin","dbP@ssw0rd") or die(mysql_error()) ;
mysql_select_db("jetstardatabase") or die(mysql_error()) ;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$options = array(
'1' => 1,
'2' => 2,
);
if (isset($_POST['list'])) {
$value = (int)$_POST['list'];
} else {
$value = 0; // default value;
}
$cmeter = $cmeter - $value;
mysql_query("INSERT orders SET quantity='$value',fbId='$fbme',fbName='$fbName', email ='$fbEmail', dealName='$dealName'" );
mysql_query("UPDATE stardeal SET cmeter='$cmeter'WHERE dealId='$dealId'");
}
?>
Share
Improve this question
asked Jan 12, 2012 at 16:01
Nicholas LimNicholas Lim
95 silver badges8 bronze badges
3
- Can you give us more details of the context ? – jbrtrnd Commented Jan 12, 2012 at 16:03
- Seriously hope this code isn't actually for JetStar! – Treffynnon Commented Jan 12, 2012 at 16:05
- @Treffynnon I hope so too, looks like he's even put the login details in! – Dunhamzzz Commented Jan 12, 2012 at 16:35
5 Answers
Reset to default 1Just put this PHP at the end of your update logic, it must be before any HTML output;
header("Location: /mypage.html");
Web pages work like this:
page (client) -> request (made in url) (server) -> new page (client)
By sending a request to the server, the server generates the new page and serves it back to the browser. You have the middle part, you need the entry and exit pages.
Like blake said, ajax or PHP would probably be prefered. Otherwise, to answer your question, you can use:
document.location = window.location.href
If you need javascript, then use this code:
<script>window.top.location='mypage.html'</script>
You cannot refresh your browser page using PHP. You have to use either META or Javascript.
Using Meta tag inside <HEAD>
and </HEAD>
:
<meta http-equiv="refresh" content="0; url=http://example./">
Using Javascript:
location.reload(true)
本文标签: javascriptRefresh Page after update phpStack Overflow
版权声明:本文标题:javascript - Refresh Page after update php - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745422954a2657983.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论