app.php從其他頁面獲取帖子值。並且該值用於查詢目的。該帖子值用於編輯app.php中的多個值。我再次發佈多個值到edit.php來更新app.php中顯示的記錄。我想要的是,當我使用<meta http-equiv="refresh" content="0;app.php" />
或<script type="text/javascript">window.history.go(-1);</script>
重新進入app.php時,app.php中的值應該從edit.php中獲取新值或更新值。我不擅長使用會話。請幫助?如何更改會話的值
app.php
$mysqli = new mysqli("localhost", "root", "", "app");
ob_start();
session_start()
<form name="myform" method="post" action="edit.php"/>
if (isset($_POST['submit'])) {
//unset the session value
$_SESSION['content'] = '';
$drop = $_POST['drop_1'];
$tier_two = $_POST['tier_two'];
$where = "WHERE a.app_cn='$drop' AND a.app_plan_no='$tier_two'";
$result1 = $mysqli->query(" query ");
<table>
while ($row = $result1->fetch_assoc()) {
<td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="' . $row['id'] . '"'.($row['pr'] == ""?"disabled ":"").' style="cursor:pointer;" class="checkbox"></td>
}
</table>
$sPageContent = ob_get_clean();
$_SESSION['content'] = $sPageContent;
echo $_SESSION['content'];
} else {
if (isset($_SESSION['content'])) {
echo $_SESSION['content'];
}
}
</form>
Edit.php
<?php
$mysqli = new mysqli("localhost", "root", "", "app");
if (isset($_POST['submit'])) {
$counter=$_POST['counter'];
$pr=$_POST['pr'];
$pr_qty=$_POST['pr_qty'];
$N = count($counter);
for($i=0; $i < $N; $i++)
{
$result = $mysqli->query("UPDATE purchase_request SET pr='$pr[$i]', total_quantity='$pr_qty[$i]' where counter='$counter[$i]'");
}
echo'<meta http-equiv="refresh" content="0;app.php" />';
}
?>
<form class="form-horizontal" action="" method="post">
<?php
$id=$_POST['checkbox'];
$N = count($id);
for($i=0; $i < $N; $i++)
{
$result1 = $mysqli->query("
SELECT a.item_name, a.item_description, a.counter, b.counter, b.pr, b.total_quantity
FROM app a
LEFT OUTER JOIN purchase_request b
ON a.counter=b.counter
WHERE a.counter='$id[$i]'
");
while ($row = $result1->fetch_assoc())
{ ?>
<input name="item_name[]" class="textbox" type="text" value="<?php echo $row['item_name'] ?>"/>
<input name="item_description[]" class="textbox" type="text" value="<?php echo $row['item_description'] ?>"/>
<input name="pr_qty[]" id="pr_qty[]" class="textbox tb1" type="text" value="<?php echo $row['total_quantity']; ?>" />
<input name="pr[]" class="textbox" type="text" value="<?php echo $row['pr'] ?>" />
?>
<input name="submit" type="submit" id="sbtBtn" value="Update">
</form>
@弗雷德-II-很好的答案,但我不明白:(我在使用會話 – user3097736
@弗雷德-II很難 - 好吧,給我一些提示,我怎麼才能得到edit.php的價值,所以我可以在app.php中更改會話 – user3097736
@ Fred-ii-我在地獄裏:( – user3097736