dtio35880438 2018-11-01 09:51
浏览 47
已采纳

仅提交填充的文本框值并丢弃empt textbox ih form php

I have form which lists all the in stock products from database with price.User will add quantity , it calculated the amounts and submits the form. in the list there are 5 products. Each time user can fill any one or all the 5. While submiting, i want to get only quantity filled values to database. I am not getting how to do it

Here is my code

<tr>
        <td><?php echo $Myrow['product']; ?></td>
        <input type="hidden" name="product_id[]" value="<?php echo Myrow['id']; ?>" />
        <td><input type="text" name="rte[]" value="<?php echo $Myrow['rate']; ?>"  readonly="readonly" class="price form-control" /></td>
        <td><input type="text" name="Qty[]"  class="Qty form-control" /></td>
         <td><input type="text" id="amount" name="amount[]"  class="amount form-control" /></td>

       </tr>
       <?php } ?>
     </tbody> 

How can is submit only non-emptied values. Please help

  • 写回答

1条回答 默认 最新

  • dousao6313 2018-11-01 10:00
    关注

    I think this could help you

    $product_id=$_POST['product_id'];
    $qty=$_POST['qty'];
    foreach ($qty as $key => $value) {
     if($value){
        .... here you can save $product_id[$key], qty and other 
     }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常