title: Few of the inputs refuse to update the db only if a banner is uploaded
body: <p>For some reasons, the data is only updated if there is an upload of image happens. So if i only insert <code>path</code> or change the option <code>status</code> it does not update the data. But altogether with any of the <code>banner</code> uploaded and change <code>path</code> or <code>status</code> at the same time, then the <code>path</code> or <code>status</code> can be updated. But i dont think i included the <code>status</code> nor <code>path</code> in the if statement of the <code>banner</code> in the controller. Can someone please enlighten me? Thanks.</p>
  
  <p>EDIT#1:</p>
  
  <p>Extra info is that the form involves around 11 rows of data. Somehow the 1st row is not affected, which means that the <code>path</code> and the <code>status</code> input for the first row can be successfully updated without any <code>banner</code> uploaded. Should there be problems with the loops?</p>
  
  <p>Controller.php</p>
  
  <pre><code>    function updateHeaderAction(Request $request){
          ini_set('max_file_uploads', 33);
          $data = $_FILES;
          $formData = $request-&gt;request-&gt;all();
          $name = array(
              1=&gt;'right1',
              2=&gt;'right2',
              3=&gt;'right3',
              4=&gt;'right4',
              5=&gt;'right5',
              6=&gt;'right6',
              7=&gt;'right7',
              8=&gt;'right8',
              9=&gt;'right9',
              10=&gt;'right10',
              11=&gt;'logo',
  
          );
          end($data['banner']['name']);
          $key = key($data['banner']['name']);
          $a = array();
          for($i=0;$i&lt;=$key;$i++){
              if(isset($data['banner']['name'][$i])){
                  if(isset($data['banner']['name'][$i][0])){
                      $img = $this-&gt;forBannerUpload('banner','storage/header/en/',null,null,true,$i,0,true,$name[$i+1]);
                      $a[$i+1]['en'] = $img;
                  }else{
                      $img = null;
                      $a[$i+1]['en'] = null;
                  }
                  if(isset($data['banner']['name'][$i][1])){
                      $img_zh = $this-&gt;forBannerUpload('banner','storage/header/hk/',null,null,true,$i,1,true,$name[$i+1]);
                      $a[$i+1]['hk'] = $img;
                  }else{
                      $img_zh = null;
                      $a[$i+1]['hk'] = null;
                  }
                  if(isset($data['banner']['name'][$i][2])){
                      $img_cn = $this-&gt;forBannerUpload('banner','storage/header/cn/',null,null,true,$i,2,true,$name[$i+1]);
                      $a[$i+1]['cn'] = $img;
                  }else{
                      $img_cn = null;
                      $a[$i+1]['cn'] = null;
                  }
              }
                  $status = $formData['status'][$i];
                  $path = $formData['path'][$i];
                  $query = new HeaderModule($this-&gt;app);
                  $query-&gt;updateHeader($i+1,$img,$img_zh,$img_cn,$status,$path);
  //            $a[] = $name[]
  //            $a[$i] = $name[$id[$i]];
  //            $img = $this-&gt;uploadImageAction('banner','storage/page_banner/',null,null,true,$id[$i],true,$name[$id[$i]]);
  //            $this-&gt;app['query']-&gt;updateBanner($id[$i],$img);
          }
  //
  //        ob_start();
  //        var_dump($a);
  //        return ob_get_clean();
          return true;
      }
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>{% for key,item in data %}
  &lt;tr&gt;
      &lt;td class="hidden-xs-portrait"&gt;
          &lt;div&gt;
              &lt;div class="ea_flag"&gt;&lt;/div&gt;
              {{ item.name }}
          &lt;/div&gt;
      &lt;/td&gt;
      &lt;td class="hidden-xs-portrait"&gt;
          {% if item.header_img_src is not null and item.header_img_src is not empty %}
              &lt;div&gt;
                  &lt;div class="es_flag" style="top: 1px;"&gt;&lt;/div&gt;
                  &lt;div&gt;EN:&lt;/div&gt;
                  &lt;img src="{{ app.request.baseUrl }}/{{ item.header_img_src }}" width="150" /&gt;
              &lt;/div&gt;
          {% endif %}
          {% if item.header_img_src_zh is not null and item.header_img_src_zh is not empty %}
              &lt;div&gt;
                  &lt;div class="hs_flag" style="top: 1px;"&gt;&lt;/div&gt;
                  &lt;div&gt;HK:&lt;/div&gt;
                  &lt;img src="{{ app.request.baseUrl }}/{{ item.header_img_src_zh }}" width="150" /&gt;
              &lt;/div&gt;
          {% endif %}
          {% if item.header_img_src_cn is not null and item.header_img_src_cn is not empty %}
              &lt;div&gt;
                  &lt;div class="cs_flag" style="top: 1px;"&gt;&lt;/div&gt;
                  &lt;div&gt;CN:&lt;/div&gt;
                  &lt;img src="{{ app.request.baseUrl }}/{{ item.header_img_src_cn }}" width="150" /&gt;
              &lt;/div&gt;
          {% endif %}
      &lt;/td&gt;
      &lt;td&gt;
          {#&lt;input type="file" class="image-upload" name="banner[1]" &gt;#}
          &lt;div class="ea_flag"&gt;&lt;/div&gt;
          &lt;input type="file" class="image-upload" name="banner[{{key}}][0]"&gt;
          &lt;div class="ha_flag"&gt;&lt;/div&gt;
          &lt;input type="file" class="image-upload" name="banner[{{key}}][1]"&gt;
          &lt;div class="ca_flag"&gt;&lt;/div&gt;
          &lt;input type="file" class="image-upload" name="banner[{{key}}][2]"&gt;
          &lt;label for="programme-status" class="control-label"&gt;Programme Status:&lt;/label&gt;
          &lt;select required="required" name="status[{{key}}]" class="form-control programme-status header-status"&gt;
              {% if item.status == 0 %}
              &lt;option value="0" selected&gt;Hidden&lt;/option&gt;
              &lt;option value="1"&gt;Show&lt;/option&gt;
              {% else %}
              &lt;option value="0"&gt;Hidden&lt;/option&gt;
              &lt;option value="1" selected&gt;Show&lt;/option&gt;
              {% endif %}
          &lt;/select&gt;
  
          &lt;div class="en_flag"&gt;&lt;/div&gt;&lt;label style="position: relative; margin-left:25px;" for="programme-link-description" class="control-label "&gt;Hyperlink:&lt;/label&gt;
          &lt;div class="controls form-group"&gt;
              &lt;input type="text" class="form-control header-path" name="path[{{key}}]" value="{{item.path}}"&gt;
          &lt;/div&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  {% endfor %}
  </code></pre>
  
  <p>Module.php </p>
  
  <pre><code>function updateHeader($id,$img,$img_zh,$img_cn,$status,$path){
      if($img!=null){
          $sql['header_img_src'] = $img;
      }
      if($img_zh!=null){
          $sql['header_img_src_zh'] = $img_zh;
      }
      if($img_cn!=null){
          $sql['header_img_src_cn'] = $img_cn;
      }
      $sql['path'] = $path;
      $sql['status'] = $status;
      return $this-&gt;app['db']-&gt;update('header',$sql, array('id' =&gt; (int)$id));
  }
  </code></pre>