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 slam rangenet++配置
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊