title: Codeigniter - Save input value in mysql
body: <p>I have an input in my code that update a value in MySQL, but is not working, if i set the value manually in PHPMyAdmin, the value display in HTML, but when i try update, return to 0.</p>
  
  <p>I have the same code to do a similar function, and have copied, and it still isn't working.</p>
  
  <p>Controller:</p>
  
  <pre><code>function ordemmobile(){
      $ordemmobile = $this-&gt;input-&gt;post('ordemmobile');
      $id    = $this-&gt;input-&gt;post('id');
  
      if($id &gt; 0){
          $data['ordemmobile'] = $ordemmobile;
          $data['id']    = $id;
  
          if( $this-&gt;categorias_model-&gt;alterar($data)){
              $ret = "success";
              $msg = "Ordem alterada com sucesso!";
          }else{
              $ret = "danger";
              $msg = "Erro ao alterar a ordem :(";
          }
      }else{
          $ret = "danger";
          $msg = "Erro ao alterar a ordem :(";
      }
  
      echo json_encode(array('status' =&gt; $ret , 'msg' =&gt; $msg));
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>echo "&lt;td&gt;&lt;input type=\"number\" name=\"ordemmobile\" value=\"".$registro-&gt;ordemmobile."\" style=\"width:80px; margin:0\" class=\"ordemmobile\"  data-id=\"".$registro-&gt;id."\" data-url=\"".base_url('adm/'.$this-&gt;router-&gt;fetch_class().'/ordemmobile')."\" /&gt;&lt;span style=\"display:none\"&gt;".$registro-&gt;ordemmobile."&lt;/span&gt;&lt;/td&gt;";
  </code></pre>
  
  <p>Model (alterar):</p>
  
  <pre><code>function alterar($data){
      $this-&gt;db-&gt;where('id',$data['id']);
      return $this-&gt;db-&gt;update('ga845_categorias',$data);
  }
  </code></pre>