title: How to show auto generate id automatically in view codeigniter
body: <p>I am a newbie in CI and I got stuck with some issues on my current project.
  So here is my question:<br></p>
  
  <p>1. I already succeded create auto generate number function for a text field, but I don't know how to show or place it automatically at my specific text field in view page whenever I hit "Create New" button.</p>
  
  <p><a href="https://ibb.co/mUr899" rel="nofollow noreferrer">https://ibb.co/mUr899</a><br>
  <a href="https://ibb.co/j9BVNU" rel="nofollow noreferrer">https://ibb.co/j9BVNU</a></p>
  
  <p>2. And let say I have used/saved one of my auto generate number on my database, I want it can check if it already used or not, if the number already used then it should generate new number.</p>
  
  <p>And here is my code:<br>
  My Controller</p>
  
  <pre><code>//------------------- input data SPL -------------------------//
  public function input()
  {
      $this-&gt;autogenerate();
      $this-&gt;load-&gt;view('spl/spl_add_view');
  }
  
  //----------------------- auto generate no_spl -------------------------//
  function autogenerate()
  {
      $kode_spl = 'SPL';
      $tgl = date("ymd");
  
      for ($counter = 1; $counter &lt;= 10; $counter++) {
          $spl_no = date('ymd', strtotime($tgl)) . str_pad($counter, 3, 0, STR_PAD_LEFT);
          echo $kode_spl . $spl_no . '&lt;br /&gt;';
      }
  }
  </code></pre>
  
  <p>My View:<br></p>
  
  <pre><code>        &lt;div class="form-group"&gt;
              &lt;label class="col-sm-2 control-label"&gt;No. SPL&lt;/label&gt;
              &lt;div class="col-sm-4"&gt;
                  &lt;input type="text" name="inospl" class="form-control" placeholder="No. SPL" value="&lt;?php echo set_value('inospl'); ?&gt;"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>can anyone help me? thank you very much.</p>