doupao6011 2015-05-23 09:24
浏览 97

表单提交后,数据不会在输入字段上更新,而数据库也会更新。

I have made this piece of code to manage counter cash on a shop, the user enters the new balance in the input field and presses the enter button. The code updates the database but it does not update the browser input field accordingly. We have to refresh the page (Using F5 or relaod button in the browser) in order to see the updated cash value. Please help me to enter the new value and the page displays the new updated value instantly.

<?php
    $cash_query = mysqli_query($link,"SELECT * FROM aks_counter");

    while ($counter_row = mysqli_fetch_array($cash_query)) 
    {
        $counter_cash = $counter_row['counter_cash'];

?>

<div class="container">
    <div id="counter_cash">
        <form method="POST">
        <input type="number" name="counter_balance" class="input_field" value="<?php echo $counter_cash; ?>">
        <input type="hidden" name="counter_hidden_id" value="<?php echo $counter_row['id']; ?>">
        </form>
<?php 
    }
        $counter_id = $_POST['counter_hidden_id'];
        $counter_balance = $_POST['counter_balance'];
        mysqli_query($link,"UPDATE aks_counter SET counter_cash=$counter_balance WHERE id=$counter_id");
?>

        &emsp;
        <h2>Counter Cash</h2>
    </div> 


</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿