以下是发生的事情:
<?php require_once("./includes/session.php"); ?>
<?php require_once("./includes/db_connection.php"); ?>
<?php require_once("./includes/functions.php"); ?>
<?php include("./includes/layouts/header.php"); ?>
<div class="wrapper">
<?php table_date(); ?>
<div id="current_wk_head" >
<?php current_table(); ?>
</div>
</div>
<div class="wrapper">
<h4 id="directions">Put a check-mark by the days you want to play!</h4>
<form name="input" action="wk1.php" method="post">
<?php week1_changes(); ?>
<div id="submit_section">
<input type="submit" name="playdaz" value="SUBMIT" class="button">
<form name="input" action="wk1.php" method="post">
<input type="submit" name="goback" value="BACK" class="button">
</form>
<p> When you click SUBMIT all days are submitted so, each day should be appropriately checked.</p>
<p> No updates within 24hrs of next play day.</p>
</div>
</div>
<iframe id="forecast_embed" type="text/html" frameborder="0" height="245" src="http://forecast.io/embed/#lat=35.795925&lon=-79.228608&name=Chapel Ridge&color=#6BB9F0&font=Open+Sans"> </iframe>
</div> <!--End container div-->
</body>
</html>
以上是用户提交日期的网页。
if (($today=="Fri") && ($hd_flag=="yes"))
{
//Friday after the cron run
echo "<div id=\"checkboxes\">
<label class=\"tag\"><input type=\"checkbox\" name=\"MON_PRI\" value=\"YES\" class=\"regular-checkbox\"/>MON_PRI</label>
<label class=\"tag\"><input type=\"checkbox\" name=\"MON_ALT\" value=\"YES\" class=\"regular-checkbox\"/>MON_ALT</label>
<label class=\"tag\"><input type=\"checkbox\" name=\"WED\" value=\"YES\" class=\"regular-checkbox\" />WED</label>
<label class=\"tag\"><input type=\"checkbox\" name=\"FRI\" value=\"YES\" class=\"regular-checkbox\" />FRI</label>
</div>";
}
elseif ($today=="Sat")
{
echo "<div id=\"checkboxes\">
<label class=\"tag\"><input type=\"checkbox\" name=\"MON_PRI\" value=\"YES\" class=\"regular-checkbox\"/>MON_PRI</label>
<label class=\"tag\"><input type=\"checkbox\" name=\"MON_ALT\" value=\"YES\" class=\"regular-checkbox\"/>MON_ALT</label>
<label class=\"tag\"><input type=\"checkbox\" name=\"WED\" value=\"YES\" class=\"regular-checkbox\" />WED</label>
<label class=\"tag\"><input type=\"checkbox\" name=\"FRI\" value=\"YES\" class=\"regular-checkbox\" />FRI</label>
</div>";
}
elseif (($today=="Mon") || ($today=="Sun"))
{
echo "<div id=\"checkboxes\">
<label class=\"tag\"><input type=\"checkbox\" name=\"WED\" value=\"YES\" class=\"regular-checkbox\" />WED</label>
<label class=\"tag\"><input type=\"checkbox\" name=\"FRI\" value=\"YES\" class=\"regular-checkbox\" />FRI</label>
</div>";
}
elseif (($today=="Tue") || ($today=="Wed"))
{
echo "<div id=\"checkboxes\">
<label class=\"tag\"><input type=\"checkbox\" name=\"FRI\" value=\"YES\" class=\"regular-checkbox\" />FRI</label>
</div>";
}
if(isset($_POST['playdaz']))
{
$LastName=$_SESSION['LAST_NAME'];
$monpri = (isset($_POST['MON_PRI'])) ? "YES" :"NO";
$monalt = (isset($_POST['MON_ALT'])) ? "YES" :"NO";
$wed = (isset($_POST['WED'])) ? "YES" :"NO";
$fri = (isset($_POST['FRI'])) ? "YES" :"NO";
//Cannot select 2 courses on the same day
if (($monpri =="NO") || ($monalt=="NO"))
{
$LastName=$_SESSION['LAST_NAME'];
if (($today=="Fri") && ($hd_flag=="yes"))
{
//Friday after the cron runs
$query = "UPDATE players SET MON_PRI='$monpri',MON_ALT='$monalt',WED='$wed',FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
elseif ($today=="Sat")
{
$query = "UPDATE players SET MON_PRI='$monpri',MON_ALT='$monalt',WED='$wed',FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
elseif (($today=="Mon")||($today=="Sun"))
{
$query = "UPDATE players SET WED='$wed',FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
elseif (($today=="Tue")||($today=="Wed"))
{
$query = "UPDATE players SET FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
}
}
上面是更新数据库的函数的一部分
有关如何制作的任何帮助,以便在用户点击按钮后表更新以提供已做出更改的反馈?
干杯!
答案 0 :(得分:0)
很容易做到。
您可以使用标题刷新功能,它将为您修复重定向属性。在使用它时,必须考虑两个基本的事情;它被正确放置在页面中并且正确的参数被传递到它中,其中包括我们应该在最终刷新到新位置之前等待多长时间。
将标题刷新放在PHP提交代码中符合逻辑的位置下方,或者更好地在PHP代码中输出任何内容之前。它必须放在任何<html>
和<!doctype>
标记之前。
对于你自己的情况,尝试这样的事情,
if (($monpri =="NO") || ($monalt=="NO"))
{
$LastName=$_SESSION['LAST_NAME'];
if (($today=="Fri") && ($hd_flag=="yes"))
{
//Friday after the cron runs
$query = "UPDATE players SET MON_PRI='$monpri',MON_ALT='$monalt',WED='$wed',FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
elseif ($today=="Sat")
{
$query = "UPDATE players SET MON_PRI='$monpri',MON_ALT='$monalt',WED='$wed',FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
elseif (($today=="Mon")||($today=="Sun"))
{
$query = "UPDATE players SET WED='$wed',FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
elseif (($today=="Tue")||($today=="Wed"))
{
$query = "UPDATE players SET FRI='$fri' WHERE LAST_NAME='$LastName'";
mysqli_query($connection, $query);
}
header("refresh:3; url=mywebpage.php?action=something&monpri=$monpri");
}
如果您需要,请在那里使用刷新。
在此之后,您尝试检查条件是否在您的网页上设置了某些内容,如果已设置,则显示数据库已相应更新。这样做;
<?php
if(isset($_REQUEST['action']) && $_REQUEST['monpri']="NO") {echo "Database updated accordingly";}?>