我有一个包含三个输入的更新表单。现在,我想从输入中的数据库中检索值,并在单击“更新”后对其进行更新,效果很好。但是,问题是我必须在按下更新按钮以查看更改(自动刷新和手动刷新)之后刷新。按下更新按钮后,我需要立即更改该值。这该怎么做?这是我的代码:
<?php
require_once 'core/init.php';
$result = $db->query("SELECT * FROM customers WHERE id = '$customer_id'");
while($res = mysqli_fetch_assoc($result)) {
$first_name = $res['first_name'];
$last_name = $res['last_name'];
$mobile_number = $res['mobile_number'];
}
if(isset($_POST['submit_0'])) {
$first_Name = ((isset($_POST['First_Name']))?sanitize($_POST['First_Name']):'');
$last_Name = ((isset($_POST['Last_Name']))?sanitize($_POST['Last_Name']):'');
$db->query("UPDATE customers SET first_name = '{$first_Name}', last_Name = '{$last_Name}' WHERE id = '{$customer_id}'");
}
?>
<form action="personal_details.php" method="post" id="personal_details">
<div class="row">
<div class="form-group col-lg-12">
<label for="First_Name" style="font-weight: bold; cursor:text;"><span style="color:red;">* </span>First Name</label>
<input type="text" name="First_Name" id="First_Name" class="form-control form-control-lg"
value="<?=$first_name;?>" style="width:770px; background-color:#EEEEEE;">
</div>
</div>
<div class="row">
<div class="form-group col-lg-12">
<label for="Last_Name" style="font-weight: bold; cursor:text;"><span style="color:red;">* </span>Last Name</label>
<input type="text" name="Last_Name" id="Last_Name" class="form-control form-control-lg"
value="<?=$last_name;?>" style="width:770px; background-color:#EEEEEE;">
</div>
</div>
<div class="row">
<div class="form-group col-lg-7">
<label for="mobile_number" style="font-weight: bold;"><span style="color:red;">* </span>Mobile Phone Number</label>
<input type="tel" name="mobile_number" id="monu" class="form-control form-control-lg"
value="<?=$mobile_number;?>" style="background-color:#EEEEEE; cursor:default;" readonly>
</div>
</div>