dougao2830 2013-02-07 07:01
浏览 38
已采纳

限制照片上传字段的想法

I have a form with 10 fields of photo upload. What I want to do is to limit 10 photo upload. Ususally after you upload 10 photos and after that the the 10 fields will appear again. But this time I want to make it limitable. For example, there are 10 upload fields and after you upload 5 photos, there will be only 5 fields left. If you delete a photo then 6 fields will apear there. For now, I'm using select count(*) to count number of rows in MySql table and I'm using :

if ($rownumber == 4) { 
    "show 6 fields" 
}

Are there any other method to do this? The method that I'm using now are so complicated and uses codeas a lot.

  • 写回答

2条回答 默认 最新

  • dqmdlo9674 2013-02-07 07:09
    关注

    Why lots of code?

    $maxuploadslots = 10;
    for($i=0; $i<$maxuploadslots; $i++)
    {
        if($i < $rownumber)
            continue;
        echo "<input...."; // I believe you add them this way, right?
        // that is "ADD 1 FIELD"
    }
    

    the for loop will run ten times, and everytime it checks against the uploaded images count if there i is smaller the rownumber it'll NOT add a new row, else it will.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度